﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:xtk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.Converters;assembly=Xceed.Wpf.Toolkit"  xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <xtk:ColorToSolidColorBrushConverter x:Key="ColorToSolidColorBrushConverter" />
    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    <DrawingBrush x:Key="CheckerBrush" Viewport="0,0,10,10" ViewportUnits="Absolute" TileMode="Tile">
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <GeometryDrawing Brush="White">
                    <GeometryDrawing.Geometry>
                        <RectangleGeometry Rect="0,0 100,100" />
                    </GeometryDrawing.Geometry>
                </GeometryDrawing>
                <GeometryDrawing Brush="LightGray">
                    <GeometryDrawing.Geometry>
                        <GeometryGroup>
                            <RectangleGeometry Rect="0,0 50,50" />
                            <RectangleGeometry Rect="50,50 50,50" />
                        </GeometryGroup>
                    </GeometryDrawing.Geometry>
                </GeometryDrawing>
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>
    <xtk:InverseBoolConverter x:Key="InverseBoolConverter" />


    <!-- generic stuff-->
    <Geometry x:Key="UpArrowGeometry">M 0 4 L 4 0 L 8 4 Z</Geometry>
    <Geometry x:Key="DownArrowGeometry">M 0 0 L 4 4 L 8 0 Z</Geometry>

    <DataTemplate x:Key="IncreaseGlyphNormalKey">
        <Path Width="7" Height="4" Data="{StaticResource UpArrowGeometry}" Fill="{DynamicResource GlyphBrush}" SnapsToDevicePixels="True" HorizontalAlignment="Center" VerticalAlignment="Center" Focusable="False" />
    </DataTemplate>
    <DataTemplate x:Key="IncreaseGlyphDisabledKey">
        <Path Width="7" Height="4" Data="{StaticResource UpArrowGeometry}" Fill="{DynamicResource BaseBorderBrush}" SnapsToDevicePixels="True" HorizontalAlignment="Center" VerticalAlignment="Center" Focusable="False" />
    </DataTemplate>

    <DataTemplate x:Key="DecreaseGlyphNormalKey">
        <Path Width="7" Height="4" Data="{StaticResource DownArrowGeometry}" Fill="{DynamicResource GlyphBrush}" SnapsToDevicePixels="True" HorizontalAlignment="Center" VerticalAlignment="Center" Focusable="False" />
    </DataTemplate>

    <DataTemplate x:Key="DecreaseGlyphDisabledKey">
        <Path Width="7" Height="4" Data="{StaticResource DownArrowGeometry}" Fill="{DynamicResource BaseBorderBrush}" SnapsToDevicePixels="True" HorizontalAlignment="Center" VerticalAlignment="Center" Focusable="False" />
    </DataTemplate>

    <Style TargetType="{x:Type xtk:ButtonChrome}">
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Background" Value="{DynamicResource ButtonBackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThickness}" />
        <Setter Property="CornerRadius" Value="{DynamicResource ComboBoxRightCornerRadius}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:ButtonChrome}">
                    <Grid >

                        <Border x:Name="OuterBorder" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
                            <Border x:Name="InnerBorder" BorderThickness="0" CornerRadius="{TemplateBinding InnerCornerRadius}" BorderBrush="{DynamicResource BaseBorderBrush}" />
                        </Border>

                        <Border x:Name="MouseOverVisual" Opacity="0" Visibility="Collapsed" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" BorderBrush="{DynamicResource SelectedBrush}">
                            <Border x:Name="MouseOverInnerVisual" BorderThickness="0" CornerRadius="0" BorderBrush="{DynamicResource SelectedBrush}" />
                        </Border>
                        <Border x:Name="PressedVisual" Opacity="0" Visibility="Collapsed" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" BorderBrush="{DynamicResource BaseBorderBrush}" >
                            <Border x:Name="PressedInnerVisual" BorderThickness="0" CornerRadius="{TemplateBinding InnerCornerRadius}" BorderBrush="{DynamicResource BaseBorderBrush}"  />
                        </Border>

                        <Border x:Name="FocusVisual" Opacity="0" Visibility="Collapsed" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" BorderBrush="{DynamicResource BaseBorderBrush}" Background="{TemplateBinding Background}">
                            <Border x:Name="FocusInnerVisual" BorderThickness="1" CornerRadius="{TemplateBinding InnerCornerRadius}" BorderBrush="{DynamicResource BaseBorderBrush}"  />
                        </Border>

                        <ContentPresenter MinWidth="{TemplateBinding MinWidth}" MinHeight="{TemplateBinding MinHeight}" Margin="{TemplateBinding Padding}" IsEnabled="{TemplateBinding IsEnabled}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" />

                    </Grid>
                    <ControlTemplate.Triggers>

                        <!-- If button is disabled, not checked, and is rendered normal -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="RenderEnabled" Value="False" />
                                <Condition Property="RenderChecked" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="OuterBorder" Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
                            <Setter TargetName="InnerBorder" Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
                            <!--<Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource BaseBrush}" />
                            <Setter TargetName="InnerBorder" Property="Background" Value="{DynamicResource BaseBrush}" />-->
                            <Setter Property="Foreground" Value="{DynamicResource DisabledBrush}" />
                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter TargetName="OuterBorder" Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" />
                            <Setter TargetName="InnerBorder" Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" />
                            <!--<Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource BaseBrush}" />
                            <Setter TargetName="InnerBorder" Property="Background" Value="{DynamicResource BaseBrush}" />-->
                            <Setter Property="Foreground" Value="{DynamicResource DisabledBrush}" />
                        </Trigger>

                        <!-- if button is enabled and pressed -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="RenderEnabled" Value="True" />
                                <Condition Property="RenderPressed" Value="True" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PressedVisual" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PressedVisual" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="00:00:00.050" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PressedVisual" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00.115">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PressedVisual" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="00:00:00.115" Value="0" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>

                        <!-- if button is enabled, is not checked, the mouse is over, and not pressed -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="RenderEnabled" Value="True" />
                                <Condition Property="RenderChecked" Value="False" />
                                <Condition Property="RenderMouseOver" Value="True" />
                                <Condition Property="RenderPressed" Value="False" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MouseOverVisual" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MouseOverVisual" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MouseOverVisual" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00.0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MouseOverVisual" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>

                        <!-- if button is enabled, checked, he mouse is not over, and it is not pressed -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="RenderEnabled" Value="True" />
                                <Condition Property="RenderChecked" Value="True" />
                                <Condition Property="RenderMouseOver" Value="False" />
                                <Condition Property="RenderPressed" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="OuterBorder" Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
                            <Setter TargetName="InnerBorder" Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
                            <Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource ButtonBackgroundBrush}" />
                        </MultiTrigger>

                        <!-- if button is focused, is enabled, not pressed, and the mouse is not over -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="RenderFocused" Value="True" />
                                <Condition Property="RenderEnabled" Value="True" />
                                <Condition Property="RenderPressed" Value="False" />
                                <Condition Property="RenderMouseOver" Value="False" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="00:00:00.25" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00.115">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="00:00:00.115" Value="0" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>

                        <!-- if not rendered normally -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="RenderNormal" Value="False" />
                                <Condition Property="RenderChecked" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="OuterBorder" Property="BorderBrush" Value="Transparent" />
                            <Setter TargetName="InnerBorder" Property="BorderBrush" Value="{x:Null}" />
                            <Setter TargetName="OuterBorder" Property="Background" Value="Transparent" />
                        </MultiTrigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ToolkitToggleButton" TargetType="ToggleButton">
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThickness}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="{DynamicResource ButtonCornerRadius}" BorderThickness="{TemplateBinding BorderThickness}" Name="mainBorder">                     
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>                            
                            <ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                            <Border Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True" CornerRadius="{DynamicResource ButtonCornerRadius}" Grid.Column="1">
                            <xtk:ButtonChrome MinWidth="22" MinHeight="22" x:Name="ToggleButtonChrome"  Visibility="{Binding ShowDropDownButton, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xtk:ColorPicker}, Converter={StaticResource BooleanToVisibilityConverter}}" RenderChecked="{Binding IsOpen, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xtk:ColorPicker}}" RenderEnabled="{Binding IsEnabled, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xtk:ColorPicker}}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}" BorderThickness="0">
                                <Grid x:Name="arrowGlyph" IsHitTestVisible="False" Grid.Column="1" Margin="5" MinWidth="20">
                                    <Path x:Name="Arrow" Width="7" Height="4" Data="M 0 0 L 4 4 L 8 0 Z" Fill="{DynamicResource GlyphBrush}" />
                                </Grid>
                            </xtk:ButtonChrome>                                
                            </Border>                            
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Fill" TargetName="Arrow" Value="{DynamicResource BaseBorderBrush}" />
                            <Setter Property="Background" Value="{DynamicResource BaseBrush}" />
                            <Setter Property="Background" TargetName="mainBorder" Value="{DynamicResource BaseBrush}" />
                            <Setter Property="Background" TargetName="ToggleButtonChrome" Value="{DynamicResource BaseBrush}" />

                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{DynamicResource SelectedBrush}" />
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{DynamicResource DarkerSelectedBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type xtk:RichTextBox}" BasedOn="{StaticResource {x:Type RichTextBox}}" />


    <!-- controls -->
    <Style TargetType="{x:Type xtk:AutoSelectTextBox}" BasedOn="{StaticResource {x:Type TextBox}}" />
    <Style TargetType="{x:Type xtk:ValueRangeTextBox}" BasedOn="{StaticResource {x:Type TextBox}}" />

    <Style TargetType="{x:Type xtk:BusyIndicator}">
        <Setter Property="OverlayStyle">
            <Setter.Value>
                <Style TargetType="Rectangle">
                    <Setter Property="Fill" Value="Black" />
                    <Setter Property="Opacity" Value="0.3" />
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="DisplayAfter" Value="00:00:00.1" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:BusyIndicator}">
                    <Grid Margin="5">
                        <Grid>                            
                            <ContentControl x:Name="content" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" IsTabStop="False" Focusable="False" />
                            <Rectangle x:Name="overlay" Style="{TemplateBinding OverlayStyle}" />
                            <ContentPresenter x:Name="busycontent" Margin="5">
                                <ContentPresenter.Content>
                                    <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                                        <Grid.Effect>
                                            <DropShadowEffect BlurRadius="10" ShadowDepth="0" Color="{DynamicResource Base6Color}" />
                                        </Grid.Effect>
                                        <Border Background="{DynamicResource BaseBrush}" BorderThickness="{DynamicResource DefaultBorderThickness}" CornerRadius="{DynamicResource DefaultCornerRadius}" >
                                            <Border.BorderBrush>
                                                <SolidColorBrush Color="{DynamicResource Base6Color}" />
                                            </Border.BorderBrush>
                                            <Border CornerRadius="0" Margin="1" Background="{DynamicResource BaseBrush}">
                                                <Grid MinWidth="150">
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition />
                                                        <RowDefinition Height="Auto" />
                                                    </Grid.RowDefinitions>
                                                    <ContentPresenter Content="{TemplateBinding BusyContent}" ContentTemplate="{TemplateBinding BusyContentTemplate}" Margin="8" />
                                                </Grid>
                                            </Border>
                                        </Border>
                                    </Grid>
                                </ContentPresenter.Content>
                            </ContentPresenter>
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsBusy" Value="True">
                            <Setter Property="Visibility" TargetName="busycontent" Value="Visible" />
                            <Setter Property="Visibility" TargetName="overlay" Value="Visible" />
                            <Setter Property="IsEnabled" TargetName="content" Value="False" />
                        </Trigger>
                        <Trigger Property="IsBusy" Value="False">
                            <Setter Property="IsEnabled" TargetName="content" Value="True" />
                            <Setter Property="Visibility" TargetName="busycontent" Value="Collapsed" />
                            <Setter Property="Visibility" TargetName="overlay" Value="Collapsed" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- spinnerbutton stuff-->
    <Style x:Key="SpinnerButtonStyle" TargetType="RepeatButton">
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Padding" Value="1,1" />
        <Setter Property="MinWidth" Value="22" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="RepeatButton">
                    <Grid>
                        <xtk:ButtonChrome x:Name="Chrome" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" CornerRadius="{TemplateBinding Tag}" RenderEnabled="{TemplateBinding IsEnabled}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderNormal="True" RenderPressed="{TemplateBinding IsPressed}" SnapsToDevicePixels="true" BorderThickness="{TemplateBinding BorderThickness}" />

                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" TargetName="Chrome" Value="{DynamicResource BaseBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <BooleanToVisibilityConverter x:Key="b2v" />
    <Style TargetType="{x:Type xtk:ButtonSpinner}">
        <Setter Property="Background" Value="{DynamicResource DarkerBaseBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="IsTabStop" Value="True" />
        <Setter Property="Padding" Value="3,0,0,0" />
        <Setter Property="MinHeight" Value="22" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:ButtonSpinner}">
                    <Border x:Name="Border" SnapsToDevicePixels="True" MinHeight="{TemplateBinding MinHeight}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{DynamicResource ComboBoxCornerRadius}">
                        <Border CornerRadius="{DynamicResource ComboBoxCornerRadius}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <ContentPresenter Focusable="False" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />

                            <Grid Grid.Column="1" Visibility="{TemplateBinding ShowButtonSpinner, Converter={StaticResource b2v}}" >
                                <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <RepeatButton Style="{StaticResource SpinnerButtonStyle}" x:Name="PART_IncreaseButton" Tag="{DynamicResource UpperInnerButtonCornerRadius}" IsTabStop="{TemplateBinding IsTabStop}" ContentTemplate="{StaticResource  IncreaseGlyphNormalKey}" />
                                <RepeatButton Style="{StaticResource SpinnerButtonStyle}" x:Name="PART_DecreaseButton" Tag="{DynamicResource LowerInnerButtonCornerRadius}" Grid.Column="1" IsTabStop="{TemplateBinding IsTabStop}" ContentTemplate="{StaticResource DecreaseGlyphNormalKey}" />
                            </Grid>
                        </Grid>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" />
                            <Setter Property="Background" Value="{DynamicResource BaseBrush}" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="BorderBrush" Value="{DynamicResource SelectedBrush}" />
                        </Trigger>
                        <Trigger SourceName="PART_IncreaseButton" Property="IsEnabled" Value="False">
                            <Setter TargetName="PART_IncreaseButton" Property="ContentTemplate" Value="{StaticResource IncreaseGlyphDisabledKey}" />
                        </Trigger>
                        <Trigger SourceName="PART_DecreaseButton" Property="IsEnabled" Value="False">
                            <Setter TargetName="PART_DecreaseButton" Property="ContentTemplate" Value="{StaticResource DecreaseGlyphDisabledKey}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!-- Watermark Text Box stuff-->
    <DataTemplate x:Key="DefWatermarkTemplate">
        <ContentControl Content="{Binding}" Foreground="{DynamicResource VeryLighterBaseBrush}" Focusable="False" />
    </DataTemplate>
    <Style TargetType="{x:Type xtk:WatermarkTextBox}">
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="Background" Value="{DynamicResource DarkerBaseBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource BaseBorderBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
        <Setter Property="Padding" Value="2" />
        <Setter Property="AllowDrop" Value="true" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
        <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
        <Setter Property="WatermarkTemplate" Value="{StaticResource DefWatermarkTemplate}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:WatermarkTextBox}">                    
                        <Border x:Name="Border" CornerRadius="{DynamicResource DefaultCornerRadius}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
                        <Grid>
                            <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="2" />
                            <ContentPresenter x:Name="PART_WatermarkHost" Content="{TemplateBinding Watermark}" ContentTemplate="{TemplateBinding WatermarkTemplate}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="False" Margin="{TemplateBinding Padding}" Visibility="Collapsed" />
                        </Grid>
                    </Border>                    
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsFocused" Value="False" />
                                <Condition Property="Text" Value="" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter Property="Visibility" TargetName="PART_WatermarkHost" Value="Visible" />
                            </MultiTrigger.Setters>
                        </MultiTrigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource SelectedBrush}" />
                        </Trigger>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource DarkerSelectedBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" />
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource BaseBrush}" />
                            <Setter Property="Foreground" Value="{DynamicResource DisabledBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!-- numeric up/down stuff, needs watermark text box stuff-->

    <Style x:Key="NumericUpDown" TargetType="{x:Type xtk:InputBase}">
        <Setter Property="Background" Value="{DynamicResource DarkerBaseBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="HorizontalContentAlignment" Value="Right" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="TextAlignment" Value="Right" />
        <Setter Property="WatermarkTemplate" Value="{StaticResource DefWatermarkTemplate}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Control">
                    <xtk:ButtonSpinner x:Name="PART_Spinner" IsTabStop="False" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" AllowSpin="{Binding AllowSpin, RelativeSource={RelativeSource TemplatedParent}}" ShowButtonSpinner="{Binding ShowButtonSpinner, RelativeSource={RelativeSource TemplatedParent}}">
                        <xtk:WatermarkTextBox x:Name="PART_TextBox" BorderThickness="0" Background="{TemplateBinding Background}" ContextMenu="{TemplateBinding ContextMenu}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}" IsTabStop="{TemplateBinding IsTabStop}" MinWidth="20" AcceptsReturn="False" Padding="{TemplateBinding Padding}" SelectAllOnGotFocus="{Binding SelectAllOnGotFocus, RelativeSource={RelativeSource TemplatedParent}}" AutoSelectBehavior="{Binding AutoSelectBehavior, RelativeSource={RelativeSource TemplatedParent}}" AutoMoveFocus="{Binding AutoMoveFocus, RelativeSource={RelativeSource TemplatedParent}}" TextAlignment="{Binding TextAlignment, RelativeSource={RelativeSource TemplatedParent}}" TextWrapping="NoWrap" TabIndex="{TemplateBinding TabIndex}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Watermark="{Binding Watermark, RelativeSource={RelativeSource TemplatedParent}}" WatermarkTemplate="{Binding WatermarkTemplate, RelativeSource={RelativeSource TemplatedParent}}" />
                    </xtk:ButtonSpinner>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{DynamicResource DisabledBrush}" />
                            <Setter Property="Background" Value="{DynamicResource BaseBrush}" />
                            <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="BorderBrush" Value="{DynamicResource SelectedBrush}" />
                        </Trigger>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter TargetName="PART_TextBox" Property="FocusManager.FocusedElement" Value="{Binding ElementName=PART_TextBox}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type xtk:DecimalUpDown}" BasedOn="{StaticResource NumericUpDown}" />
    <Style TargetType="{x:Type xtk:DoubleUpDown}" BasedOn="{StaticResource NumericUpDown}" />
    <Style TargetType="{x:Type xtk:IntegerUpDown}" BasedOn="{StaticResource NumericUpDown}" />
    <Style TargetType="{x:Type xtk:ShortUpDown}" BasedOn="{StaticResource NumericUpDown}" />
    <Style TargetType="{x:Type xtk:LongUpDown}" BasedOn="{StaticResource NumericUpDown}" />
    <Style TargetType="{x:Type xtk:ByteUpDown}" BasedOn="{StaticResource NumericUpDown}" />
    <Style TargetType="{x:Type xtk:SingleUpDown}" BasedOn="{StaticResource NumericUpDown}" />
    <Style TargetType="{x:Type xtk:TimeSpanUpDown}" BasedOn="{StaticResource NumericUpDown}" />


    <!-- color canvas stuff-->
    <Style x:Key="ColorCanvasTextBoxStyle" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
        <Setter Property="Background" Value="Transparent" />
        <Style.Triggers>
            <Trigger Property="IsFocused" Value="False">
                <Setter Property="BorderBrush" Value="Transparent" />
            </Trigger>
        </Style.Triggers>
    </Style>
    <Style x:Key="SliderRepeatButtonStyle" TargetType="{x:Type RepeatButton}">
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="IsTabStop" Value="false" />
        <Setter Property="Focusable" Value="false" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="{TemplateBinding Background}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="VerticalSlideThumbStyle" TargetType="{x:Type Thumb}">
        <Setter Property="Focusable" Value="false" />
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="Height" Value="12" />
        <Setter Property="Width" Value="11" />
        <Setter Property="Foreground" Value="Gray" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Canvas SnapsToDevicePixels="true">
                        <Path x:Name="LeftArrow" Stretch="Fill" StrokeLineJoin="Round" Stroke="{DynamicResource GlyphBrush}" Fill="{DynamicResource GlyphBrush}" Data="F1 M 276.761,316L 262.619,307.835L 262.619,324.165L 276.761,316 Z " RenderTransformOrigin="0.5,0.5" Width="6" Height="8">
                            <Path.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform />
                                    <SkewTransform />
                                    <RotateTransform />
                                    <TranslateTransform Y="6" X="-3" />
                                </TransformGroup>
                            </Path.RenderTransform>
                        </Path>
                        <Path x:Name="RightArrow" Stretch="Fill" StrokeLineJoin="Round" Stroke="{DynamicResource GlyphBrush}" Fill="{DynamicResource GlyphBrush}" Data="F1 M 276.761,316L 262.619,307.835L 262.619,324.165L 276.761,316 Z " RenderTransformOrigin="0.5,0.5" Width="6" Height="8">
                            <Path.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform />
                                    <SkewTransform />
                                    <RotateTransform Angle="-180" />
                                    <TranslateTransform Y="6" X="8" />
                                </TransformGroup>
                            </Path.RenderTransform>
                        </Path>
                    </Canvas>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type xtk:ColorCanvas}">
        <Setter Property="Background" Value="{DynamicResource BaseBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:ColorCanvas}">
                    <Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="{DynamicResource DefaultCornerRadius}" Padding="3">
                        <Grid Margin="2">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid HorizontalAlignment="Center">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="200" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>

                                <Border BorderThickness="1" BorderBrush="{DynamicResource BaseBorderBrush}" ClipToBounds="True" Background="{StaticResource CheckerBrush}">
                                    <Canvas x:Name="PART_ColorShadingCanvas" Width="200" Height="100" HorizontalAlignment="Left" VerticalAlignment="Top">
                                        <Rectangle x:Name="ColorShadingRectangle" Height="{Binding ElementName=PART_ColorShadingCanvas, Path=Height}" Width="{Binding ElementName=PART_ColorShadingCanvas, Path=Width}" Fill="{Binding SelectedColor, ElementName=PART_SpectrumSlider, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
                                        <Rectangle x:Name="WhiteGradient" Width="{Binding ElementName=PART_ColorShadingCanvas,Path=Width}" Height="{Binding ElementName=PART_ColorShadingCanvas,Path=Height}">
                                            <Rectangle.Fill>
                                                <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                                                    <GradientStop Offset="0" Color="#ffffffff" />
                                                    <GradientStop Offset="1" Color="Transparent" />
                                                </LinearGradientBrush>
                                            </Rectangle.Fill>
                                        </Rectangle>
                                        <Rectangle x:Name="BlackGradient" Width="{Binding ElementName=PART_ColorShadingCanvas,Path=Width}" Height="{Binding ElementName=PART_ColorShadingCanvas,Path=Height}">
                                            <Rectangle.Fill>
                                                <LinearGradientBrush StartPoint="0,1" EndPoint="0, 0">
                                                    <GradientStop Offset="0" Color="#ff000000" />
                                                    <GradientStop Offset="1" Color="#00000000" />
                                                </LinearGradientBrush>
                                            </Rectangle.Fill>
                                        </Rectangle>
                                        <Canvas x:Name="PART_ColorShadeSelector" Width="10" Height="10" IsHitTestVisible="False">
                                            <Ellipse Width="10" Height="10" StrokeThickness="3" Stroke="#FFFFFFFF" IsHitTestVisible="False" />
                                            <Ellipse Width="10" Height="10" StrokeThickness="1" Stroke="#FF000000" IsHitTestVisible="False" />
                                        </Canvas>
                                    </Canvas>
                                </Border>

                                <Border Grid.Row="1" Margin="0,5,0,0">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <Border Background="{StaticResource CheckerBrush}" Height="22" Margin="2,0,2,0" BorderThickness="1" BorderBrush="{DynamicResource BaseBorderBrush}">
                                            <Rectangle x:Name="SelectedColor" Fill="{Binding SelectedColor, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
                                        </Border>
                                        <TextBox x:Name="PART_HexadecimalTextBox" Grid.Column="1" Margin="2,0,2,0" VerticalAlignment="Center" Style="{StaticResource ColorCanvasTextBoxStyle}" />
                                    </Grid>
                                </Border>

                                <Border Grid.Column="1" Grid.RowSpan="2" Margin="4,-8,0,0" ClipToBounds="False">
                                    <xtk:ColorSpectrumSlider x:Name="PART_SpectrumSlider" VerticalAlignment="Stretch" />
                                </Border>
                            </Grid>

                            <Border MinWidth="180" Grid.Row="1" BorderThickness="1" ClipToBounds="True" Margin="0,10,0,0">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>

                                    <TextBlock Grid.Row="0" Grid.Column="0" Text="R" VerticalAlignment="Center" />
                                    <Slider x:Name="PART_RSlider" Maximum="255" SmallChange="1" LargeChange="10" TickFrequency="1" Grid.Row="0" Grid.Column="1" Margin="4,6,4,6" Value="{Binding R, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center" />
                                    <TextBox Grid.Row="0" Grid.Column="2" Text="{Binding Value, ElementName=PART_RSlider}" VerticalAlignment="Center" Style="{StaticResource ColorCanvasTextBoxStyle}" />

                                    <TextBlock Grid.Row="1" Grid.Column="0" Text="G" VerticalAlignment="Center" />
                                    <Slider x:Name="PART_GSlider" Maximum="255" SmallChange="1" LargeChange="10" TickFrequency="1" Grid.Row="1" Grid.Column="1" Margin="4,6,4,6" Value="{Binding G, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center" />
                                    <TextBox Grid.Row="1" Grid.Column="2" Text="{Binding Value, ElementName=PART_GSlider}" VerticalAlignment="Center" Style="{StaticResource ColorCanvasTextBoxStyle}" />

                                    <TextBlock Grid.Row="2" Grid.Column="0" Text="B" VerticalAlignment="Center" />
                                    <Slider x:Name="PART_BSlider" Maximum="255" SmallChange="1" LargeChange="10" TickFrequency="1" Grid.Row="2" Grid.Column="1" Margin="4,6,4,6" Value="{Binding B, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center" />
                                    <TextBox Grid.Row="2" Grid.Column="3" Text="{Binding Value, ElementName=PART_BSlider}" VerticalAlignment="Center" Style="{StaticResource ColorCanvasTextBoxStyle}" />

                                    <TextBlock Grid.Row="3" Grid.Column="0" Text="A" VerticalAlignment="Center" Visibility="{Binding Path=UsingAlphaChannel, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                    <Slider x:Name="PART_OpacitySlider" Grid.Row="3" Grid.Column="1" Maximum="255" SmallChange="1" LargeChange="10" Margin="4,6,4,6" Value="{Binding Path=A, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center" Visibility="{Binding Path=UsingAlphaChannel, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                    <TextBox Grid.Row="3" Grid.Column="3" Text="{Binding Value, ElementName=PART_OpacitySlider}" VerticalAlignment="Center" Style="{StaticResource ColorCanvasTextBoxStyle}" Visibility="{Binding Path=UsingAlphaChannel, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                </Grid>
                            </Border>
                        </Grid>
                        
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        
    </Style>
    <Style TargetType="{x:Type xtk:ColorSpectrumSlider}">
        <Setter Property="Orientation" Value="Vertical" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Foreground" Value="{DynamicResource GlyphBrush}" />
        <Setter Property="Minimum" Value="1" />
        <Setter Property="Maximum" Value="360" />
        <Setter Property="TickFrequency" Value="0.001" />
        <Setter Property="IsSnapToTickEnabled" Value="True" />
        <Setter Property="IsDirectionReversed" Value="False" />
        <Setter Property="IsMoveToPointEnabled" Value="True" />
        <Setter Property="Value" Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:ColorSpectrumSlider}">
                    <Grid>
                        <Border x:Name="PART_TrackBackground" BorderBrush="{DynamicResource BaseBorderBrush}" BorderThickness="1" Width="15" Margin="0,8,0,0">
                            <Rectangle x:Name="PART_SpectrumDisplay" Stretch="Fill" VerticalAlignment="Stretch" />
                        </Border>

                        <Track Name="PART_Track">
                            <Track.DecreaseRepeatButton>
                                <RepeatButton Style="{StaticResource SliderRepeatButtonStyle}" Command="Slider.DecreaseLarge" />
                            </Track.DecreaseRepeatButton>
                            <Track.IncreaseRepeatButton>
                                <RepeatButton Style="{StaticResource SliderRepeatButtonStyle}" Command="Slider.IncreaseLarge" />
                            </Track.IncreaseRepeatButton>
                            <Track.Thumb>
                                <Thumb Style="{StaticResource VerticalSlideThumbStyle}" />
                            </Track.Thumb>
                        </Track>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!-- color picker stuff, needs color canvas-->
    <Style x:Key="ColorItemContainerStyle" TargetType="{x:Type ListBoxItem}">
        <Setter Property="ToolTip" Value="{Binding Name}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Grid ToolTip="{Binding Name}">
                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
                        <Border Background="Transparent" BorderBrush="Transparent" x:Name="_outerBorder" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="{DynamicResource DefaultBorderThickness}" CornerRadius="{DynamicResource DefaultCornerRadius}">
                            <Border Background="Transparent" BorderBrush="Transparent" x:Name="_innerBorder" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="_outerBorder" Property="BorderBrush" Value="{DynamicResource SelectedBrush}" />
                            <Setter TargetName="_innerBorder" Property="BorderBrush" Value="Transparent" />
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="_outerBorder" Property="BorderBrush" Value="{DynamicResource DarkerSelectedBrush}" />
                            <Setter TargetName="_innerBorder" Property="BorderBrush" Value="Transparent" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <DataTemplate x:Key="ColorItemTemplate">
        <Grid>
            <Border Background="{StaticResource CheckerBrush}" BorderBrush="Black" BorderThickness="1" Margin="2,2,2,2">
                <Rectangle Width="14" Height="14">
                    <Rectangle.Style>
                        <Style TargetType="Rectangle">
                            <Setter Property="Fill" Value="{Binding Color, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
                        </Style>
                    </Rectangle.Style>
                </Rectangle>
            </Border>
        </Grid>
    </DataTemplate>
    <Style x:Key="ColorDisplayStyle" TargetType="ContentControl">
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Border Background="{StaticResource CheckerBrush}">
                        <Rectangle Fill="{Binding SelectedColor, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xtk:ColorPicker}, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
                    </Border>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ColorListStyle" TargetType="ListBox">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <WrapPanel Width="200" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemContainerStyle" Value="{StaticResource ColorItemContainerStyle}" />
        <Setter Property="ItemTemplate" Value="{StaticResource ColorItemTemplate}" />
        <Setter Property="SelectionMode" Value="Single" />
    </Style>
    <Style TargetType="{x:Type xtk:ColorPicker}">
        <Setter Property="Background" Value="{DynamicResource ButtonBackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
        <Setter Property="ButtonStyle" Value="{StaticResource ToolkitToggleButton}" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:ColorPicker}">
                    <Grid>
                        <ToggleButton x:Name="PART_ColorPickerToggleButton" IsTabStop="True" MinHeight="22" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" IsChecked="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" IsHitTestVisible="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverter}}" Style="{TemplateBinding ButtonStyle}">
                            <Border Background="Transparent" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0" CornerRadius="{DynamicResource DefaultCornerRadius}">
                            <Grid>
                                <ContentControl x:Name="ColorOnly" Style="{StaticResource ColorDisplayStyle}" />

                                <Border x:Name="ColorAndName"  Visibility="Hidden" >
                                    <StackPanel Orientation="Horizontal">
                                        <ContentControl HorizontalAlignment="Left" Width="20" Margin="2,1,4,1" Style="{StaticResource ColorDisplayStyle}" BorderThickness="1" BorderBrush="{DynamicResource BaseBorderBrush}" />
                                        <TextBlock Text="{Binding SelectedColorText, RelativeSource={RelativeSource TemplatedParent}}" Foreground="{DynamicResource TextBrush}" VerticalAlignment="Center" />
                                    </StackPanel>
                                </Border>
                            </Grid>
                            </Border>
                        </ToggleButton>
                        <Border ClipToBounds="True">
                            <Border Name="glow" CornerRadius="{DynamicResource ButtonCornerRadius}" BorderThickness="{DynamicResource GlowBorderThickness}" BorderBrush="{DynamicResource ButtonGlowBrush}" Margin="{DynamicResource GlowBorderMargin}" Visibility="Collapsed" Effect="{DynamicResource ButtonHoverGlowEffect}" />
                        </Border>                        <Popup x:Name="PART_ColorPickerPalettePopup" VerticalAlignment="Bottom" IsOpen="{Binding ElementName=PART_ColorPickerToggleButton, Path=IsChecked}" StaysOpen="False"  AllowsTransparency="True" Focusable="False" HorizontalOffset="1" VerticalOffset="1" PopupAnimation="None" Width="{TemplateBinding ActualWidth}" MinWidth="240">
                            <Border BorderThickness="{DynamicResource DefaultBorderThickness}" CornerRadius="{DynamicResource DefaultCornerRadius}" Margin="10,0,10,10" Background="{DynamicResource DarkerBaseBrush}" BorderBrush="{DynamicResource PopupBorderBrush}" Padding="3">
                                <Border.Effect>
                                    <DropShadowEffect BlurRadius="10" ShadowDepth="0" Color="{DynamicResource Base6Color}" />
                                </Border.Effect>
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>

                                    <Grid x:Name="_colorPaletteHost" Visibility="Collapsed" Margin="4">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>

                                        <!-- Available Colors -->
                                        <Grid Grid.Row="1" Visibility="{TemplateBinding ShowAvailableColors, Converter={StaticResource BooleanToVisibilityConverter}}">
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition />
                                                </Grid.RowDefinitions>
                                                <TextBlock Text="{TemplateBinding AvailableColorsHeader}" Background="{DynamicResource MenuHoverBrush}" Foreground="{DynamicResource TextBrush}" Padding="2" Margin="0,0,0,1" />
                                                <ListBox x:Name="PART_AvailableColors" Grid.Row="1" ItemsSource="{Binding AvailableColors, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ColorListStyle}" />
                                            </Grid>
                                        </Grid>

                                        <!-- Standard Colors-->
                                        <Grid Grid.Row="2" Visibility="{TemplateBinding ShowStandardColors, Converter={StaticResource BooleanToVisibilityConverter}}">
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                </Grid.RowDefinitions>
                                                <TextBlock Text="{TemplateBinding StandardColorsHeader}" Foreground="{DynamicResource TextBrush}" Background="{DynamicResource MenuHoverBrush}" Padding="2" Margin="0,1,0,1" />
                                                <ListBox x:Name="PART_StandardColors" Grid.Row="1" ItemsSource="{Binding StandardColors, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ColorListStyle}" />
                                            </Grid>
                                        </Grid>

                                        <!-- Recent Colors-->
                                        <Grid Grid.Row="3" Margin="0,1,0,1" Visibility="{TemplateBinding ShowRecentColors, Converter={StaticResource BooleanToVisibilityConverter}}">
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                </Grid.RowDefinitions>
                                                <TextBlock Foreground="{DynamicResource TextBrush}" Text="{TemplateBinding RecentColorsHeader}" Background="{DynamicResource MenuHoverBrush}" Padding="2" Margin="0,1,0,1" />
                                                <ListBox x:Name="PART_RecentColors" Grid.Row="1" ItemsSource="{Binding RecentColors, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ColorListStyle}" />
                                            </Grid>
                                        </Grid>
                                    </Grid>

                                    <!-- ColorCanvas -->
                                    <Grid x:Name="_colorCanvasHost" Visibility="Collapsed">
                                        <xtk:ColorCanvas Background="Transparent" BorderThickness="0" UsingAlphaChannel="{Binding UsingAlphaChannel, RelativeSource={RelativeSource TemplatedParent}}" SelectedColor="{Binding SelectedColor, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </Grid>

                                    <Separator Grid.Row="1" HorizontalAlignment="Stretch" Margin="5,0,5,0" Visibility="{TemplateBinding ShowAdvancedButton, Converter={StaticResource BooleanToVisibilityConverter}}" />

                                    <!-- More Colors Button -->
                                    <Button x:Name="PART_ColorModeButton" Grid.Row="2" Margin="5" Visibility="{TemplateBinding ShowAdvancedButton, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                </Grid>
                            </Border>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="glow" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <Trigger Property="DisplayColorAndName" Value="True">
                            <Setter TargetName="ColorOnly" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="ColorAndName" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <Trigger Property="ColorMode" Value="ColorPalette">
                            <Setter TargetName="_colorPaletteHost" Property="Visibility" Value="Visible" />
                            <Setter TargetName="_colorCanvasHost" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="PART_ColorModeButton" Property="Content" Value="Advanced" />
                        </Trigger>
                        <Trigger Property="ColorMode" Value="ColorCanvas">
                            <Setter TargetName="_colorPaletteHost" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="_colorCanvasHost" Property="Visibility" Value="Visible" />
                            <Setter TargetName="PART_ColorModeButton" Property="Content" Value="Standard" />
                        </Trigger>
                        <Trigger Property="ShowDropDownButton" Value="False">
                            <Setter Property="BorderThickness" Value="1" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" TargetName="PART_ColorPickerToggleButton" />
                        </Trigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>



    <!-- calculator stuff -->
    <xtk:CalculatorMemoryToVisibilityConverter x:Key="CalculatorMemoryToVisibilityConverter" />
    <Style x:Key="CalculatorOperatorButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid x:Name="Control">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PART_Default" Storyboard.TargetProperty="Opacity" To="0" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PART_MouseOver" Storyboard.TargetProperty="Opacity" To="1" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PART_Default" Storyboard.TargetProperty="Opacity" To="0" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PART_Pressed" Storyboard.TargetProperty="Opacity" To="1" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PART_Default" Storyboard.TargetProperty="Opacity" To=".5" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="Opacity" To=".5" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="MemoryStates">
                                <VisualState x:Name="EmptyMemory" />
                                <VisualState x:Name="MemoryAssigned">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PART_Border1" Storyboard.TargetProperty="Opacity" To="0" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PART_Border2" Storyboard.TargetProperty="Opacity" To="1" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border Background="Transparent" BorderBrush="{x:Null}" BorderThickness="0" CornerRadius="2" Margin="0,0,0,-1" Opacity="0.5" />
                        <Grid x:Name="PART_Default">
                            <Border BorderThickness="0" CornerRadius="2" Background="Transparent">
                                <Grid>
                                    <Border Name="PART_Border1" BorderThickness="1" CornerRadius="2" Background="{DynamicResource ButtonBackgroundBrush}" BorderBrush="{DynamicResource BaseBorderBrush}">

                                    </Border>
                                    <Border Name="PART_Border2" BorderThickness="1" CornerRadius="2" Background="{DynamicResource ButtonBackgroundBrush}" BorderBrush="{DynamicResource BaseBorderBrush}">

                                    </Border>
                                </Grid>
                            </Border>
                        </Grid>
                        <Grid x:Name="PART_MouseOver" Opacity="0">
                            <Border BorderThickness="1" CornerRadius="2" Background="{DynamicResource ButtonBackgroundBrush}" BorderBrush="{DynamicResource SelectedBrush}">

                            </Border>
                        </Grid>
                        <Grid x:Name="PART_Pressed" Opacity="0">
                            <Border BorderThickness="1" CornerRadius="2" Background="{DynamicResource ButtonBackgroundPressedBrush}" BorderBrush="{DynamicResource DarkerSelectedBrush}">

                            </Border>
                        </Grid>
                        <ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="CalculatorClearButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Foreground" Value="{DynamicResource SelectedBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid x:Name="Control">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PART_Default" Storyboard.TargetProperty="Opacity" To="0" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PART_MouseOver" Storyboard.TargetProperty="Opacity" To="1" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PART_Default" Storyboard.TargetProperty="Opacity" To="0" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PART_Pressed" Storyboard.TargetProperty="Opacity" To="1" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PART_Default" Storyboard.TargetProperty="Opacity" To=".5" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="Opacity" To=".5" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border Background="Transparent" BorderBrush="{x:Null}" BorderThickness="0" CornerRadius="2" Margin="0,0,0,-1" Opacity="0.5" />
                        <Grid x:Name="PART_Default">
                            <Border BorderThickness="1" CornerRadius="2" Background="{DynamicResource ButtonBackgroundBrush}" BorderBrush="{DynamicResource DarkerSelectedBrush}">

                            </Border>
                        </Grid>
                        <Grid x:Name="PART_MouseOver" Opacity="0">
                            <Border BorderThickness="1" CornerRadius="2" Background="{DynamicResource ButtonBackgroundBrush}" BorderBrush="{DynamicResource SelectedBrush}">

                            </Border>
                        </Grid>
                        <Grid x:Name="PART_Pressed" Opacity="0">
                            <Border BorderThickness="1" CornerRadius="2" Background="{DynamicResource ButtonBackgroundPressedBrush}" BorderBrush="{DynamicResource DarkerSelectedBrush}">

                            </Border>
                        </Grid>
                        <ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="CalculatorDigitButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid x:Name="Control">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PART_Default" Storyboard.TargetProperty="Opacity" To="0" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PART_MouseOver" Storyboard.TargetProperty="Opacity" To="1" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PART_Default" Storyboard.TargetProperty="Opacity" To="0" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PART_Pressed" Storyboard.TargetProperty="Opacity" To="1" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PART_Default" Storyboard.TargetProperty="Opacity" To=".5" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="Opacity" To=".5" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border BorderBrush="{x:Null}" BorderThickness="0" Background="Transparent" CornerRadius="3" Margin="0,0,0,-1" Opacity="0.5" />
                        <Grid x:Name="PART_Default">
                            <Border BorderThickness="1" CornerRadius="2" Background="{DynamicResource ButtonBackgroundBrush}" BorderBrush="{DynamicResource BaseBorderBrush}">

                            </Border>
                        </Grid>
                        <Grid x:Name="PART_MouseOver" Opacity="0">
                            <Border BorderThickness="1" CornerRadius="2" Background="{DynamicResource ButtonBackgroundBrush}" BorderBrush="{DynamicResource SelectedBrush}">

                            </Border>
                        </Grid>
                        <Grid x:Name="PART_Pressed" Opacity="0">
                            <Border BorderThickness="1" CornerRadius="2" Background="{DynamicResource ButtonBackgroundPressedBrush}" BorderBrush="{DynamicResource DarkerSelectedBrush}">

                            </Border>
                        </Grid>
                        <ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" TargetName="PART_Default" Value="{DynamicResource BaseBrush}" />
                            <Setter Property="Background" TargetName="PART_Pressed" Value="{DynamicResource BaseBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <ControlTemplate x:Key="CalculatorButtonPanel" TargetType="{x:Type ContentControl}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="3" />
                <ColumnDefinition />
                <ColumnDefinition Width="3" />
                <ColumnDefinition />
                <ColumnDefinition Width="3" />
                <ColumnDefinition />
                <ColumnDefinition Width="3" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="3" />
                <RowDefinition />
                <RowDefinition Height="3" />
                <RowDefinition />
                <RowDefinition Height="3" />
                <RowDefinition />
                <RowDefinition Height="3" />
                <RowDefinition />
                <RowDefinition Height="3" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Button Grid.Column="0" Grid.Row="0" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="MC" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorOperatorButtonStyle}" />

            <Button Grid.Column="2" Grid.Row="0" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="MR" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorOperatorButtonStyle}" />

            <Button Grid.Column="0" Grid.Row="2" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Back" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorOperatorButtonStyle}" Grid.RowSpan="1" />

            <Button Grid.Column="2" Grid.Row="2" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Cancel" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorClearButtonStyle}" />

            <Button Grid.Column="4" Grid.Row="2" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Clear" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorClearButtonStyle}" Grid.ColumnSpan="1" Grid.RowSpan="1" />

            <Button Grid.Column="4" Grid.Row="0" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="MS" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorOperatorButtonStyle}" />

            <Button Grid.Column="6" Grid.Row="0" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="MAdd" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorOperatorButtonStyle}" Margin="0" />

            <Button Grid.Column="8" Grid.Row="0" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="MSub" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorOperatorButtonStyle}" />

            <Button Grid.Column="6" Grid.Row="2" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Negate" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorOperatorButtonStyle}" />

            <Button Grid.Column="8" Grid.Row="2" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Sqrt" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorOperatorButtonStyle}" />

            <Button Grid.Column="0" Grid.Row="4" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Seven" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorDigitButtonStyle}" />

            <Button Grid.Column="2" Grid.Row="4" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Eight" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorDigitButtonStyle}" />

            <Button Grid.Column="4" Grid.Row="4" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Nine" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorDigitButtonStyle}" />

            <Button Grid.Column="6" Grid.Row="4" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Divide" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorOperatorButtonStyle}" />

            <Button Grid.Column="8" Grid.Row="4" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Percent" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorOperatorButtonStyle}" />

            <Button Grid.Column="0" Grid.Row="6" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Four" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorDigitButtonStyle}" />

            <Button Grid.Column="2" Grid.Row="6" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Five" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorDigitButtonStyle}" />

            <Button Grid.Column="4" Grid.Row="6" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Six" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorDigitButtonStyle}" />

            <Button Grid.Column="6" Grid.Row="6" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Multiply" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorOperatorButtonStyle}" />

            <Button Grid.Column="8" Grid.Row="6" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Fraction" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorOperatorButtonStyle}" />

            <Button Grid.Column="0" Grid.Row="8" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="One" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorDigitButtonStyle}" />

            <Button Grid.Column="2" Grid.Row="8" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Two" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorDigitButtonStyle}" />

            <Button Grid.Column="4" Grid.Row="8" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Three" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorDigitButtonStyle}" />

            <Button Grid.Column="6" Grid.Row="8" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Subtract" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorOperatorButtonStyle}" />

            <Button Grid.Column="8" Grid.Row="8" Grid.RowSpan="3" MinWidth="28" MinHeight="55" xtk:Calculator.CalculatorButtonType="Equal" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorOperatorButtonStyle}" />

            <Button Grid.Column="0" Grid.Row="10" Grid.ColumnSpan="3" MinWidth="59" MinHeight="26" xtk:Calculator.CalculatorButtonType="Zero" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorDigitButtonStyle}" />

            <Button Grid.Column="4" Grid.Row="10" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Decimal" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorDigitButtonStyle}" />

            <Button Grid.Column="6" Grid.Row="10" MinWidth="28" MinHeight="26" xtk:Calculator.CalculatorButtonType="Add" Command="xtk:CalculatorCommands.CalculatorButtonClick" Style="{StaticResource CalculatorOperatorButtonStyle}" />
        </Grid>
    </ControlTemplate>
    <Style TargetType="{x:Type xtk:Calculator}">
        <Setter Property="Background" Value="{DynamicResource BaseBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:Calculator}">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{DynamicResource DefaultCornerRadius}">
                        <Grid Margin="10">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <Border x:Name="PART_Display" Margin="0,0,0,10" Background="{DynamicResource BaseBrush}" BorderBrush="{DynamicResource BaseBorderBrush}" BorderThickness="{DynamicResource DefaultBorderThickness}" CornerRadius="{DynamicResource DefaultCornerRadius}">
                                <StackPanel>
                                    <Path Stretch="Fill" Height="9" Width="9" Fill="Transparent" Data="F1 M 508.172,390L 506.031,390L 504.612,393.385C 504.174,394.477 503.788,395.533 503.453,396.555L 503.417,396.555C 503.334,395.528 503.206,394.471 503.035,393.385L 502.454,390L 500.301,390L 498.637,399L 500.226,399L 500.807,395.537C 500.903,394.973 501,394.379 501.099,393.756C 501.198,393.133 501.287,392.534 501.367,391.957L 501.402,391.957C 501.444,392.514 501.499,393.08 501.567,393.655C 501.635,394.231 501.712,394.776 501.8,395.292L 502.382,398.871L 503.7,398.871L 505.231,395.233C 505.445,394.724 505.663,394.187 505.884,393.622C 506.105,393.057 506.313,392.502 506.508,391.957L 506.543,391.957C 506.411,393.11 506.304,394.292 506.223,395.502L 505.979,399L 507.637,399L 508.172,390 Z " HorizontalAlignment="Left" VerticalAlignment="Top" Margin="4,4,0,0" Visibility="{Binding Memory, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource CalculatorMemoryToVisibilityConverter}}" />
                                    <TextBlock FontSize="18" HorizontalAlignment="Right" Margin="0,0,4,0" Text="{Binding DisplayText, RelativeSource={RelativeSource TemplatedParent}}" />
                                </StackPanel>
                            </Border>
                            <ContentControl x:Name="PART_CalculatorButtonPanel" Grid.Row="1" Template="{StaticResource CalculatorButtonPanel}" DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}" />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter TargetName="PART_Display" Property="Background" Value="{DynamicResource DarkerBaseBrush}" />
                            <Setter TargetName="PART_Display" Property="BorderBrush" Value="{DynamicResource DarkerSelectedBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type xtk:CalculatorUpDown}">
        <Setter Property="Background" Value="{DynamicResource DarkerBaseBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThickness}" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Foreground" Value="{DynamicResource GlyphBrush}" />
        <Setter Property="HorizontalContentAlignment" Value="Right" />
        <Setter Property="TextAlignment" Value="Right" />
        <Setter Property="WatermarkTemplate" Value="{StaticResource DefWatermarkTemplate}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:CalculatorUpDown}">
                    <Grid>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <xtk:ButtonSpinner x:Name="PART_Spinner" IsTabStop="False" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" AllowSpin="{TemplateBinding AllowSpin}" ShowButtonSpinner="{TemplateBinding ShowButtonSpinner}">
                                <xtk:WatermarkTextBox x:Name="PART_TextBox" BorderThickness="0" Background="{TemplateBinding Background}" ContextMenu="{TemplateBinding ContextMenu}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}" MinWidth="20" AcceptsReturn="False" Padding="0" SelectAllOnGotFocus="{TemplateBinding SelectAllOnGotFocus}" AutoSelectBehavior="{TemplateBinding AutoSelectBehavior}" AutoMoveFocus="{TemplateBinding AutoMoveFocus}" TextAlignment="{TemplateBinding TextAlignment}" TextWrapping="NoWrap" TabIndex="{TemplateBinding TabIndex}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Watermark="{TemplateBinding Watermark}" WatermarkTemplate="{TemplateBinding WatermarkTemplate}" />
                            </xtk:ButtonSpinner>
                            <ToggleButton x:Name="_calculatorToggleButton" Grid.Column="1" Focusable="False" IsChecked="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}}" IsHitTestVisible="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverter}}">
                                <Grid x:Name="arrowGlyph" IsHitTestVisible="False" Grid.Column="1" Margin="5" MinWidth="20">
                                    <Path x:Name="Arrow" Width="7" Height="4" Data="M 0 0 L 4 4 L 8 0 Z" Fill="{TemplateBinding Foreground}" />
                                </Grid>
                            </ToggleButton>
                        </Grid>
                        <Popup AllowsTransparency="True" x:Name="PART_CalculatorPopup" IsOpen="{Binding IsChecked, ElementName=_calculatorToggleButton}" StaysOpen="False" Width="{TemplateBinding ActualWidth}">
                            <Border BorderThickness="1" Margin="11,0,11,11" BorderBrush="{DynamicResource PopupBorderBrush}">
                                <StackPanel>
                                    <xtk:Calculator x:Name="PART_Calculator"  BorderThickness="0" DisplayText="{Binding DisplayText, RelativeSource={RelativeSource TemplatedParent}}" Memory="{Binding Memory, RelativeSource={RelativeSource TemplatedParent}}" Precision="{Binding Precision, RelativeSource={RelativeSource TemplatedParent}}" />
                                </StackPanel>
                                <Border.Effect>
                                    <DropShadowEffect ShadowDepth="0" BlurRadius="10" Color="{DynamicResource Base6Color}" />
                                </Border.Effect>
                            </Border>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{DynamicResource BaseBorderBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- check combo box stuff-->
    <Style TargetType="{x:Type xtk:CheckComboBox}">
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="Background" Value="{DynamicResource ButtonBackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource ComboBoxBorderThickness}" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="Padding" Value="2" />
        <Setter Property="ScrollViewer.CanContentScroll" Value="true" />
        <Setter Property="ScrollViewer.PanningMode" Value="Both" />
        <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:CheckComboBox}">
                    <Border>
                        <Grid>
                            <Popup x:Name="PART_Popup" AllowsTransparency="true" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" StaysOpen="False" Margin="0" PopupAnimation="None" Placement="Bottom" Width="{TemplateBinding ActualWidth}">
                                <Border x:Name="DropDownBorder" Margin="10" MaxHeight="{Binding MaxDropDownHeight,  RelativeSource={RelativeSource TemplatedParent}}" BorderThickness="{DynamicResource DefaultBorderThickness}" CornerRadius="{DynamicResource DefaultCornerRadius}" Background="{DynamicResource DarkerBaseBrush}">
                                    <Border.BorderBrush>
                                        <SolidColorBrush Color="{DynamicResource Base6Color}" />
                                    </Border.BorderBrush>
                                    <ScrollViewer x:Name="DropDownScrollViewer">
                                        <Grid RenderOptions.ClearTypeHint="Enabled">
                                            <Canvas HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
                                                <Rectangle x:Name="OpaqueRect" Fill="{Binding Background, ElementName=DropDownBorder}" Height="{Binding ActualHeight, ElementName=DropDownBorder}" Width="{Binding ActualWidth, ElementName=DropDownBorder}" />
                                            </Canvas>
                                            <ItemsPresenter x:Name="PART_ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                        </Grid>
                                    </ScrollViewer>
                                    <Border.Effect>
                                        <DropShadowEffect ShadowDepth="0" BlurRadius="10" Color="{DynamicResource Base6Color}" />
                                    </Border.Effect>
                                </Border>
                            </Popup>

                            <Border>
                                <ToggleButton x:Name="PART_DropDownButton"  Content="{TemplateBinding Text}" BorderBrush="{TemplateBinding BorderBrush}"  Background="{TemplateBinding Background}" MinWidth="22" Focusable="False" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ToolkitToggleButton}" Padding="0" IsHitTestVisible="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverter}}" />
                            </Border>
                            <Border ClipToBounds="True">
                                <Border Name="glow" CornerRadius="{DynamicResource ComboBoxCornerRadius}" BorderThickness="{DynamicResource GlowBorderThickness}" BorderBrush="{DynamicResource ButtonGlowBrush}" Margin="{DynamicResource GlowBorderMargin}" Visibility="Collapsed" Effect="{DynamicResource ButtonHoverGlowEffect}" />
                            </Border>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="BorderBrush" Value="{DynamicResource SelectedBrush}" />
                            <Setter Property="Visibility" TargetName="glow" Value="Visible" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource DisabledBrush}" />
                            <Setter TargetName="PART_DropDownButton" Property="Foreground" Value="{DynamicResource DisabledBrush}" />
                            <Setter Property="Background" Value="{DynamicResource BaseBrush}" />
                            <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type xtk:CheckListBox}">
        <Setter Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
        <Setter Property="Background" Value="{DynamicResource DarkerBaseBrush}" />
        <Setter Property="KeyboardNavigation.TabNavigation" Value="Once" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:CheckListBox}">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{DynamicResource DefaultCornerRadius}">
                        <ScrollViewer Padding="{TemplateBinding Padding}" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </ScrollViewer>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="BorderBrush" Value="{DynamicResource SelectedBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" Value="{DynamicResource BaseBrush}" />
                            <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" />
                            <Setter Property="Foreground" Value="{DynamicResource DisabledBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--child window stuff -->
    <Style TargetType="{x:Type xtk:ChildWindow}">
        <Setter Property="MinWidth" Value="140" />
        <Setter Property="Background" Value="{DynamicResource BaseBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BaseBrush}" />
        <Setter Property="MinHeight" Value="40" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:ChildWindow}">
                    <Grid x:Name="PART_Root">
                        <Grid.Resources>
                            <Style x:Key="FocusVisualStyle" TargetType="Control">
                                <Setter Property="BorderBrush" Value="Black" />
                                <Setter Property="Background" Value="Transparent" />
                                <Setter Property="Margin" Value="-1" />
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate>
                                            <Rectangle Stroke="{TemplateBinding BorderBrush}" Fill="{TemplateBinding Background}" Margin="{TemplateBinding Margin}" StrokeDashArray="4 3" StrokeThickness="0.5">
                                                <Rectangle.RenderTransform>
                                                    <TranslateTransform x:Name="_translateTransform" X="{Binding Left}" Y="{Binding Top}" />
                                                </Rectangle.RenderTransform>
                                            </Rectangle>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Grid.Resources>
                        <Grid x:Name="PART_WindowRoot" HorizontalAlignment="Left" VerticalAlignment="Top" MinWidth="{TemplateBinding MinWidth}" MinHeight="{TemplateBinding MinHeight}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
                            <xtk:WindowControl x:Name="PART_WindowControl" Caption="{TemplateBinding Caption}" CaptionForeground="{TemplateBinding CaptionForeground}" CaptionShadowBrush="{TemplateBinding CaptionShadowBrush}" CaptionIcon="{TemplateBinding CaptionIcon}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" IsActive="{TemplateBinding IsActive}" WindowBackground="{TemplateBinding WindowBackground}" WindowInactiveBackground="{TemplateBinding WindowInactiveBackground}" WindowBorderBrush="{TemplateBinding WindowBorderBrush}" WindowBorderThickness="{TemplateBinding WindowBorderThickness}" CloseButtonVisibility="{TemplateBinding CloseButtonVisibility}" CloseButtonStyle="{TemplateBinding CloseButtonStyle}" WindowOpacity="{TemplateBinding WindowOpacity}" Content="{TemplateBinding Content}" WindowStyle="{TemplateBinding WindowStyle}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
                            </xtk:WindowControl>
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="WindowState" Value="Closed">
                            <Setter Property="Visibility" Value="Collapsed" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!-- Datetime stuff-->
    <Style TargetType="{x:Type xtk:DateTimePicker}">
        <Setter Property="Background" Value="{DynamicResource DarkerBaseBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="HorizontalContentAlignment" Value="Right" />
        <Setter Property="TextAlignment" Value="Right" />
        <Setter Property="TimeWatermarkTemplate" Value="{StaticResource DefWatermarkTemplate}" />
        <Setter Property="WatermarkTemplate" Value="{StaticResource DefWatermarkTemplate}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:DateTimePicker}">
                    <Border>
                        <Grid>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <xtk:ButtonSpinner x:Name="PART_Spinner" IsTabStop="False" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" AllowSpin="{TemplateBinding AllowSpin}" ShowButtonSpinner="{TemplateBinding ShowButtonSpinner}">
                                    <xtk:WatermarkTextBox x:Name="PART_TextBox" BorderThickness="0" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}" MinWidth="20" AcceptsReturn="False" Padding="0" TextAlignment="{TemplateBinding TextAlignment}" TextWrapping="NoWrap" Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}}" TabIndex="{TemplateBinding TabIndex}" Watermark="{TemplateBinding Watermark}" WatermarkTemplate="{TemplateBinding WatermarkTemplate}" />
                                </xtk:ButtonSpinner>

                                <ToggleButton x:Name="_calendarToggleButton" Grid.Column="1" Focusable="False" IsChecked="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}}" IsHitTestVisible="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverter}}" Tag="{DynamicResource ButtonCornerRadius}" IsEnabled="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverter}}">
                                    <Grid x:Name="arrowGlyph" IsHitTestVisible="False" Grid.Column="1" Margin="5" MinWidth="18">
                                        <Path x:Name="Arrow" Width="7" Height="4" Data="M 0 0 L 4 4 L 8 0 Z" Fill="{TemplateBinding Foreground}">
                                         
                                        </Path>
                                    </Grid>                                   
                                </ToggleButton>
                            </Grid>                            <Popup x:Name="PART_Popup" IsOpen="{Binding IsChecked, ElementName=_calendarToggleButton}" StaysOpen="False" AllowsTransparency="True" Width="{TemplateBinding ActualWidth}">
                                <Border BorderThickness="{DynamicResource DefaultBorderThickness}" CornerRadius="{DynamicResource DefaultCornerRadius}" Background="{DynamicResource DarkerBaseBrush}" BorderBrush="{DynamicResource PopupBorderBrush}" Padding="3" Margin="10,0,10,10">
                                    <Border.Effect>
                                        <DropShadowEffect BlurRadius="10" ShadowDepth="0" Color="{DynamicResource Base6Color}" />
                                    </Border.Effect> 
                                    <StackPanel>
                                        <Calendar x:Name="PART_Calendar" BorderThickness="0" />
                                        <xtk:TimePicker x:Name="PART_TimeUpDown" Background="{DynamicResource DarkerBaseBrush}" Foreground="{DynamicResource TextBrush}" Format="{TemplateBinding TimeFormat}" FormatString="{TemplateBinding TimeFormatString}" Value="{Binding Value, RelativeSource={RelativeSource TemplatedParent}}" Minimum="{Binding Minimum, RelativeSource={RelativeSource TemplatedParent}}" Maximum="{Binding Maximum, RelativeSource={RelativeSource TemplatedParent}}" ClipValueToMinMax="{Binding ClipValueToMinMax, RelativeSource={RelativeSource TemplatedParent}}" Watermark="{TemplateBinding TimeWatermark}" WatermarkTemplate="{TemplateBinding TimeWatermarkTemplate}" Visibility="{TemplateBinding TimePickerVisibility}" />
                                    </StackPanel>
                                </Border>
                            </Popup>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{DynamicResource BaseBorderBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="DateTimeUpDown" TargetType="{x:Type xtk:DateTimeUpDown}">
        <Setter Property="Background" Value="{DynamicResource DarkerBaseBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="HorizontalContentAlignment" Value="Right" />
        <Setter Property="TextAlignment" Value="Right" />
        <Setter Property="WatermarkTemplate" Value="{StaticResource DefWatermarkTemplate}" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:DateTimeUpDown}">
                    <xtk:ButtonSpinner x:Name="PART_Spinner" IsTabStop="False" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" AllowSpin="{TemplateBinding AllowSpin}" ShowButtonSpinner="{TemplateBinding ShowButtonSpinner}">
                        <xtk:WatermarkTextBox x:Name="PART_TextBox" BorderThickness="0" Background="Transparent" ContextMenu="{TemplateBinding ContextMenu}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}" MinWidth="20" AcceptsReturn="False" Padding="{TemplateBinding Padding}" TextAlignment="{TemplateBinding TextAlignment}" TextWrapping="NoWrap" TabIndex="{TemplateBinding TabIndex}" Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}}" Watermark="{TemplateBinding Watermark}" WatermarkTemplate="{TemplateBinding WatermarkTemplate}" />
                    </xtk:ButtonSpinner>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter TargetName="PART_TextBox" Property="FocusManager.FocusedElement" Value="{Binding ElementName=PART_TextBox}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="TimeItemStyle" TargetType="ListBoxItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBoxItem">
                    <Border Name="Border" SnapsToDevicePixels="true">
                        <ContentPresenter Margin="4" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource MenuHoverBrush}" />
                            <Setter Property="Foreground" Value="{DynamicResource SelectedBrush}" />
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource MenuHoverBrush}" />
                            <Setter Property="Foreground" Value="{DynamicResource DarkerSelectedBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <xtk:TimeFormatToDateTimeFormatConverter x:Key="TimeFormatToDateTimeFormatConverter" />
    <Style TargetType="{x:Type xtk:TimePicker}">
        <Setter Property="WatermarkTemplate" Value="{StaticResource DefWatermarkTemplate}" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:TimePicker}">
                    <Border>
                        <Grid>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <xtk:DateTimeUpDown x:Name="PART_TimeUpDown" BorderThickness="1,1,0,1" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" ContextMenu="{TemplateBinding ContextMenu}" AllowSpin="{TemplateBinding AllowSpin}" TabIndex="{TemplateBinding TabIndex}" Padding="{TemplateBinding Padding}" Format="{TemplateBinding Format, Converter={StaticResource TimeFormatToDateTimeFormatConverter}}" FormatString="{TemplateBinding FormatString}" ShowButtonSpinner="{TemplateBinding ShowButtonSpinner}" Value="{Binding Value, RelativeSource={RelativeSource TemplatedParent}}" Minimum="{Binding Minimum, RelativeSource={RelativeSource TemplatedParent}}" Maximum="{Binding Maximum, RelativeSource={RelativeSource TemplatedParent}}" ClipValueToMinMax="{Binding ClipValueToMinMax, RelativeSource={RelativeSource TemplatedParent}}" Watermark="{TemplateBinding Watermark}" WatermarkTemplate="{TemplateBinding WatermarkTemplate}" TextAlignment="{TemplateBinding TextAlignment}" />
                                <ToggleButton x:Name="_timePickerToggleButton" Grid.Column="1" Focusable="False" IsChecked="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ToolkitToggleButton}" IsHitTestVisible="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverter}}" />
                            </Grid>
                            <Popup x:Name="PART_Popup" IsOpen="{Binding IsChecked, ElementName=_timePickerToggleButton}" StaysOpen="False" AllowsTransparency="True" Width="{TemplateBinding ActualWidth}" MaxHeight="300">
                                <Border BorderThickness="1" Background="{DynamicResource DarkerBaseBrush}" BorderBrush="{DynamicResource PopupBorderBrush}" Margin="10,0,10,10">
                                    <Border.Effect>
                                        <DropShadowEffect BlurRadius="10" ShadowDepth="0" Color="{DynamicResource Base6Color}" />
                                    </Border.Effect>
                                    <Grid>
                                        <ListBox x:Name="PART_TimeListItems" BorderThickness="0" DisplayMemberPath="Display" ItemContainerStyle="{StaticResource TimeItemStyle}" />
                                    </Grid>
                                </Border>
                            </Popup>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter TargetName="PART_TimeUpDown" Property="FocusManager.FocusedElement" Value="{Binding ElementName=PART_TimeUpDown}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type xtk:DateTimeUpDown}" BasedOn="{StaticResource DateTimeUpDown}" />

    <Style TargetType="{x:Type xtk:Selector}">
        <Setter Property="Background" Value="{DynamicResource DarkerBaseBrush}" />
    </Style>
    <Style TargetType="{x:Type xtk:SelectorItem}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="IsTabStop" Value="False" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:SelectorItem}">
                    <Border x:Name="_background" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <CheckBox Foreground="{TemplateBinding Foreground}" IsChecked="{Binding IsSelected, RelativeSource={RelativeSource TemplatedParent}}" Content="{TemplateBinding Content}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" ContentTemplate="{TemplateBinding ContentTemplate}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="_background" Property="Background" Value="{DynamicResource MenuHoverBrush}" />
                            <Setter Property="Foreground" Value="{DynamicResource SelectedBrush}" />
                        </Trigger>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Foreground" Value="{DynamicResource DarkerSelectedBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style TargetType="{x:Type xtk:SplitButton}">
        <Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThickness}" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Padding" Value="3" />
        <Setter Property="MinHeight" Value="22" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:SplitButton}">
                    <Grid x:Name="MainGrid" SnapsToDevicePixels="True">
                        <xtk:ButtonChrome x:Name="ControlChrome" Background="{TemplateBinding Background}" RenderEnabled="{TemplateBinding IsEnabled}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <!--<ColumnDefinition Width="Auto" />-->
                                </Grid.ColumnDefinitions>
                                <Button Panel.ZIndex="2" x:Name="PART_ActionButton" Margin="0" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Padding="{TemplateBinding Padding}">
                                    <Button.Template>
                                        <ControlTemplate TargetType="Button">
                                            <ContentPresenter />
                                        </ControlTemplate>
                                    </Button.Template>
                                    <Grid>
                                        <xtk:ButtonChrome x:Name="ActionButtonChrome" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{DynamicResource ButtonCornerRadius}" RenderEnabled="{TemplateBinding IsEnabled}" RenderMouseOver="{Binding IsMouseOver, ElementName=PART_ActionButton}" RenderPressed="{Binding IsPressed, ElementName=PART_ActionButton}">
                                            <ContentPresenter Name="ActionButtonContent" Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="true" />
                                        </xtk:ButtonChrome>
                                    </Grid>
                                </Button>
                                <ToggleButton Style="{DynamicResource ToolkitToggleButton}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0" Panel.ZIndex="3" Padding="15" HorizontalAlignment="Right" x:Name="PART_ToggleButton" Grid.Column="1" IsTabStop="False" IsChecked="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"  IsHitTestVisible="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverter}}">
                                    <ToggleButton.Template>
                                        <ControlTemplate TargetType="ToggleButton">
                                            <ContentPresenter />
                                        </ControlTemplate>
                                    </ToggleButton.Template>
                                    <Grid Width="25" Height="25">
                                        <xtk:ButtonChrome x:Name="ToggleButtonChrome" Padding="1,0,1,0" BorderThickness="0" Background="Transparent" RenderChecked="{TemplateBinding IsOpen}" RenderEnabled="{TemplateBinding IsEnabled}" RenderMouseOver="{Binding IsMouseOver, ElementName=PART_ToggleButton}" RenderPressed="{Binding IsPressed, ElementName=PART_ToggleButton}">
                                            <Grid x:Name="arrowGlyph" IsHitTestVisible="False" Margin="4,3,4,3">
                                                <Path x:Name="Arrow" Width="7" Height="4" Data="M 0 0 L 4 4 L 8 0 Z" Fill="{DynamicResource GlyphBrush}" />
                                            </Grid>
                                            <!--<xtk:ButtonChrome.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter Property="Fill" TargetName="Arrow" Value="{DynamicResource SelectedBrush}" />
                                                </Trigger>
                                            </xtk:ButtonChrome.Triggers>-->
                                        </xtk:ButtonChrome>
                                    </Grid>
                                </ToggleButton>
                                <Border ClipToBounds="True">
                                    <Border Name="glow" CornerRadius="{DynamicResource ButtonCornerRadius}" BorderThickness="{DynamicResource GlowBorderThickness}" BorderBrush="{DynamicResource ButtonGlowBrush}" Margin="{DynamicResource GlowBorderMargin}" Visibility="Collapsed" Effect="{DynamicResource ButtonHoverGlowEffect}" />
                                </Border>
                            </Grid>
                        </xtk:ButtonChrome>

                        <Popup x:Name="PART_Popup" HorizontalOffset="1" VerticalOffset="1" AllowsTransparency="True" StaysOpen="False" Placement="Bottom" Focusable="False" IsOpen="{Binding IsChecked, ElementName=PART_ToggleButton}" MinWidth="{TemplateBinding ActualWidth}">
                            <!-- TODO: Create Popup Styles that can be reused on all popups in the toolkit-->
                            <Border BorderThickness="{DynamicResource DefaultBorderThickness}" Margin="10,0,10,10" Background="{DynamicResource DarkerBaseBrush}" BorderBrush="{DynamicResource PopupBorderBrush}" CornerRadius="{DynamicResource DefaultCornerRadius}">
                                <ContentPresenter x:Name="PART_ContentPresenter" Content="{TemplateBinding DropDownContent}" />
                                <Border.Effect>
                                    <DropShadowEffect ShadowDepth="0" BlurRadius="10" Color="{DynamicResource Base6Color}" />
                                </Border.Effect>
                            </Border>
                            
                        </Popup>

                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="glow" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Fill" TargetName="Arrow" Value="{DynamicResource DisabledBrush}" />
                            <Setter Property="Background" TargetName="ActionButtonChrome" Value="{DynamicResource BaseBrush}" />
                            <Setter Property="Background" TargetName="ControlChrome" Value="{DynamicResource BaseBrush}" />
                            <Setter Property="BorderBrush" TargetName="ControlChrome" Value="{DynamicResource DisabledBorderBrush}" />
                            <Setter Property="BorderBrush" TargetName="ActionButtonChrome" Value="{DynamicResource DisabledBorderBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!-- RichTextBox stuff -->
    <ControlTemplate x:Key="ThumbControlTemplate" TargetType="{x:Type Thumb}">
        <Border Background="Transparent" Cursor="Hand" ToolTip="Click to Drag">
            <StackPanel VerticalAlignment="Center" Width="75">
                <Line SnapsToDevicePixels="True" Stretch="Fill" StrokeDashArray="1,2" StrokeThickness="1" X1="0" X2="1" Margin=".5">
                    <Line.Stroke>
                        <SolidColorBrush Color="{DynamicResource TextColor}" />
                    </Line.Stroke>
                </Line>
                <Line SnapsToDevicePixels="True" Stretch="Fill" StrokeDashArray="1,2" StrokeThickness="1" X1="0" X2="1" Margin=".5">
                    <Line.Stroke>
                        <SolidColorBrush Color="{DynamicResource TextColor}" />
                    </Line.Stroke>
                </Line>
                <Line SnapsToDevicePixels="True" Stretch="Fill" StrokeDashArray="1,2" StrokeThickness="1" X1="0" X2="1" Margin=".5">
                    <Line.Stroke>
                        <SolidColorBrush Color="{DynamicResource TextColor}" />
                    </Line.Stroke>
                </Line>
            </StackPanel>
        </Border>
    </ControlTemplate>
    <Style x:Key="FormatBarToggleButtonStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Height" Value="22" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="ToolTipService.InitialShowDelay" Value="900" />
        <Setter Property="ToolTipService.ShowDuration" Value="20000" />
        <Setter Property="ToolTipService.BetweenShowDelay" Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid SnapsToDevicePixels="True">
                        <Border x:Name="OuterBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" />
                        <Border x:Name="MiddleBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent">
                            <Border x:Name="InnerBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" Padding="{TemplateBinding Padding}">
                                <StackPanel x:Name="StackPanel" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
                                    <ContentPresenter x:Name="Content" Content="{TemplateBinding Content}" Margin="1" RenderOptions.BitmapScalingMode="NearestNeighbor" VerticalAlignment="Center" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                                </StackPanel>
                            </Border>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" TargetName="OuterBorder" Value="{DynamicResource VeryLighterBaseBrush}" />
                            <Setter Property="BorderBrush" TargetName="OuterBorder" Value="{DynamicResource SelectedBrush}" />
                        </Trigger>

                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" TargetName="Content" Value="0.5" />
                            <Setter Property="TextElement.Foreground" TargetName="OuterBorder" Value="{DynamicResource DisabledBrush}" />
                        </Trigger>

                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="Background" TargetName="OuterBorder" Value="{DynamicResource VeryLighterBaseBrush}" />
                            <Setter Property="BorderBrush" TargetName="OuterBorder" Value="{DynamicResource DarkerSelectedBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="FontColorButtonStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Height" Value="22" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="ToolTipService.InitialShowDelay" Value="900" />
        <Setter Property="ToolTipService.ShowDuration" Value="20000" />
        <Setter Property="ToolTipService.BetweenShowDelay" Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid SnapsToDevicePixels="True">
                        <Border x:Name="OuterBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" />
                        <Border x:Name="MiddleBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent">
                            <Border x:Name="InnerBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" Padding="{TemplateBinding Padding}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Grid>
                                        <Image Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/RichTextBoxFormatBar/Images/FontColorPicker16.png" Width="16" Height="16" />
                                        <Rectangle Grid.Row="1" Height="4" Margin="0,12,0,0" Fill="{Binding SelectedColor, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xtk:ColorPicker}, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
                                    </Grid>
                                    <Path Grid.Column="1" Width="7" Height="4" Data="M 0 0 L 4 4 L 8 0 Z" Fill="{DynamicResource GlyphBrush}" />
                                </Grid>
                            </Border>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" TargetName="OuterBorder" Value="{DynamicResource VeryLighterBaseBrush}" />
                            <Setter Property="BorderBrush" TargetName="OuterBorder" Value="{DynamicResource  SelectedBrush}" />
                            <Setter Property="BorderBrush" TargetName="InnerBorder" Value="#80FFFFFF" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="TextElement.Foreground" TargetName="OuterBorder" Value="{DynamicResource DisabledBrush}" />
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="Background" TargetName="OuterBorder" Value="{DynamicResource  VeryLighterBaseBrush}" />
                            <Setter Property="BorderBrush" TargetName="OuterBorder" Value="{DynamicResource  DarkerSelectedBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="FontBackgrounColorButtonStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Background" Value="White" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Height" Value="22" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="ToolTipService.InitialShowDelay" Value="900" />
        <Setter Property="ToolTipService.ShowDuration" Value="20000" />
        <Setter Property="ToolTipService.BetweenShowDelay" Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid SnapsToDevicePixels="True">
                        <Border x:Name="OuterBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" />
                        <Border x:Name="MiddleBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent">
                            <Border x:Name="InnerBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" Padding="{TemplateBinding Padding}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Grid>
                                        <Image Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/RichTextBoxFormatBar/Images/TextHighlightColorPicker16.png" Width="16" Height="16" />
                                        <Rectangle Grid.Row="1" Height="4" Margin="0,12,0,0" Fill="{Binding SelectedColor, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xtk:ColorPicker}, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
                                    </Grid>
                                    <Path Grid.Column="1" Width="7" Height="4" Data="M 0 0 L 4 4 L 8 0 Z" Fill="{DynamicResource GlyphBrush}" />
                                </Grid>
                            </Border>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" TargetName="OuterBorder" Value="{DynamicResource VeryLighterBaseBrush}" />
                            <Setter Property="BorderBrush" TargetName="OuterBorder" Value="{DynamicResource SelectedBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="TextElement.Foreground" TargetName="OuterBorder" Value="{DynamicResource DisabledBrush}" />
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="Background" TargetName="OuterBorder" Value="{DynamicResource VeryLighterBaseBrush}" />
                            <Setter Property="BorderBrush" TargetName="OuterBorder" Value="{DynamicResource  DarkerSelectedBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <ControlTemplate x:Key="richTextBoxFormatBarTemplate" TargetType="{x:Type xtk:RichTextBoxFormatBar}">
        <ControlTemplate.Resources>
            <Style TargetType="{x:Type Separator}" BasedOn="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
        </ControlTemplate.Resources>
        <Border CornerRadius="{DynamicResource DefaultCornerRadius}" BorderThickness="{DynamicResource DefaultBorderThickness}" Background="{DynamicResource LighterBaseBrush}">
            <Border.BorderBrush>
                <SolidColorBrush Color="{DynamicResource Base6Color}" />
            </Border.BorderBrush>
            <Grid Margin="5,0,5,5">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Thumb x:Name="_dragWidget" Height="10" Template="{StaticResource ThumbControlTemplate}" />

                <StackPanel Grid.Row="1">
                    <StackPanel Orientation="Horizontal">
                        <ComboBox x:Name="_cmbFontFamilies" IsEditable="True" Width="100" ToolTip="Font Family" Margin="3,3,3,0" />

                        <ComboBox x:Name="_cmbFontSizes" IsEditable="True" Width="43" ToolTip="Font Size" Margin="3,3,3,0" />

                        <Separator />

                        <ToggleButton x:Name="_btnBullets" Style="{StaticResource FormatBarToggleButtonStyle}" Margin="3,3,1,0" Command="EditingCommands.ToggleBullets" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}" ToolTip="Bullets">
                            <Image Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/RichTextBoxFormatBar/Images/Bullets16.png" />
                        </ToggleButton>

                        <ToggleButton x:Name="_btnNumbers" Style="{StaticResource FormatBarToggleButtonStyle}" Margin="1,3,3,0" Command="EditingCommands.ToggleNumbering" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}" ToolTip="Numbering">
                            <Image Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/RichTextBoxFormatBar/Images/Numbering16.png" />
                        </ToggleButton>

                    </StackPanel>

                    <StackPanel Orientation="Horizontal" Margin="0,3,0,0">
                        <ToggleButton x:Name="_btnBold" Style="{StaticResource FormatBarToggleButtonStyle}" Command="EditingCommands.ToggleBold" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}" ToolTip="Bold" Margin="3,3,1,0">
                            <Image Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/RichTextBoxFormatBar/Images/Bold16.png" />
                        </ToggleButton>
                        <ToggleButton x:Name="_btnItalic" Style="{StaticResource FormatBarToggleButtonStyle}" Command="{x:Static EditingCommands.ToggleItalic}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}" ToolTip="Italic" Margin="1,3,1,0">
                            <Image Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/RichTextBoxFormatBar/Images/Italic16.png" />
                        </ToggleButton>
                        <ToggleButton x:Name="_btnUnderline" Style="{StaticResource FormatBarToggleButtonStyle}" Command="{x:Static EditingCommands.ToggleUnderline}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}" ToolTip="Underline" Margin="1,3,3,0">
                            <Image Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/RichTextBoxFormatBar/Images/Underline16.png" />
                        </ToggleButton>

                        <Separator />

                        <RadioButton x:Name="_btnAlignLeft" Style="{StaticResource FormatBarToggleButtonStyle}" Command="{x:Static EditingCommands.AlignLeft}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}" ToolTip="Align Left" Margin="3,3,1,0">
                            <Image Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/RichTextBoxFormatBar/Images/LeftAlign16.png" />
                        </RadioButton>
                        <RadioButton x:Name="_btnAlignCenter" Style="{StaticResource FormatBarToggleButtonStyle}" Command="{x:Static EditingCommands.AlignCenter}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}" ToolTip="Align Center" Margin="1,3,1,0">
                            <Image Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/RichTextBoxFormatBar/Images/CenterAlign16.png" />
                        </RadioButton>
                        <RadioButton x:Name="_btnAlignRight" Style="{StaticResource FormatBarToggleButtonStyle}" Command="{x:Static EditingCommands.AlignRight}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}" ToolTip="Align Right" Margin="1,3,3,0">
                            <Image Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/RichTextBoxFormatBar/Images/RightAlign16.png" />
                        </RadioButton>

                        <Separator />

                        <xtk:ColorPicker x:Name="_cmbFontBackgroundColor" BorderThickness="0" ButtonStyle="{StaticResource FontBackgrounColorButtonStyle}" ToolTip="Text Highlight Color" Margin="3,3,3,0" />

                        <xtk:ColorPicker x:Name="_cmbFontColor" BorderThickness="0" ButtonStyle="{StaticResource FontColorButtonStyle}" ToolTip="Font Color" Margin="3,3,3,0" />

                    </StackPanel>

                </StackPanel>
            </Grid>
        </Border>
    </ControlTemplate>
    <Style TargetType="{x:Type xtk:RichTextBoxFormatBar}">
        <Setter Property="Template" Value="{StaticResource richTextBoxFormatBarTemplate}" />
        <Setter Property="Effect">
            <Setter.Value>
                <DropShadowEffect BlurRadius="10" Direction="0" ShadowDepth="0" Opacity="1" Color="{DynamicResource Base6Color}" />
            </Setter.Value>
        </Setter>
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="IsTabStop" Value="false" />
    </Style>
    
    
    
    <!-- PropertyGrid stuff-->
    <xtk:ExpandableObjectMarginConverter x:Key="ExpandableObjectMarginConverter" />
    <x:Static x:Key="EmptyString" Member="sys:String.Empty" />

    <!-- PropertyGrid numeric Editors -->
    <Style TargetType="{x:Type xtk:PropertyGridEditorByteUpDown}" BasedOn="{StaticResource NumericUpDown}">
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsKeyboardFocusWithin" Value="False" />
                    <Condition Property="IsMouseOver" Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush" Value="Transparent" />
                <Setter Property="ShowButtonSpinner" Value="False" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>
    <Style TargetType="{x:Type xtk:PropertyGridEditorDecimalUpDown}" BasedOn="{StaticResource NumericUpDown}">
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsKeyboardFocusWithin" Value="False" />
                    <Condition Property="IsMouseOver" Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush" Value="Transparent" />
                <Setter Property="ShowButtonSpinner" Value="False" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>
    <Style TargetType="{x:Type xtk:PropertyGridEditorDoubleUpDown}" BasedOn="{StaticResource NumericUpDown}">
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsKeyboardFocusWithin" Value="False" />
                    <Condition Property="IsMouseOver" Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush" Value="Transparent" />
                <Setter Property="ShowButtonSpinner" Value="False" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>
    <Style TargetType="{x:Type xtk:PropertyGridEditorIntegerUpDown}" BasedOn="{StaticResource NumericUpDown}">
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsKeyboardFocusWithin" Value="False" />
                    <Condition Property="IsMouseOver" Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush" Value="Transparent" />
                <Setter Property="ShowButtonSpinner" Value="False" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>
    <Style TargetType="{x:Type xtk:PropertyGridEditorLongUpDown}" BasedOn="{StaticResource NumericUpDown}">
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsKeyboardFocusWithin" Value="False" />
                    <Condition Property="IsMouseOver" Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush" Value="Transparent" />
                <Setter Property="ShowButtonSpinner" Value="False" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>
    <Style TargetType="{x:Type xtk:PropertyGridEditorShortUpDown}" BasedOn="{StaticResource NumericUpDown}">
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsKeyboardFocusWithin" Value="False" />
                    <Condition Property="IsMouseOver" Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush" Value="Transparent" />
                <Setter Property="ShowButtonSpinner" Value="False" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>
    <Style TargetType="{x:Type xtk:PropertyGridEditorSingleUpDown}" BasedOn="{StaticResource NumericUpDown}">
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsKeyboardFocusWithin" Value="False" />
                    <Condition Property="IsMouseOver" Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush" Value="Transparent" />
                <Setter Property="ShowButtonSpinner" Value="False" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>
    <!-- PropertyGrid DateTime Editors -->
    <Style TargetType="{x:Type xtk:PropertyGridEditorDateTimeUpDown}" BasedOn="{StaticResource DateTimeUpDown}">
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsKeyboardFocusWithin" Value="False" />
                    <Condition Property="IsMouseOver" Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush" Value="Transparent" />
                <Setter Property="ShowButtonSpinner" Value="False" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>
    <!-- PropertyGrid TimeSpan Editors -->
    <Style TargetType="{x:Type xtk:PropertyGridEditorTimeSpanUpDown}" >
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsKeyboardFocusWithin" Value="False" />
                    <Condition Property="IsMouseOver" Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush" Value="Transparent" />
                <Setter Property="ShowButtonSpinner" Value="False" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>
    <!-- PropertyGrid ComboBox Editors -->
    <Style TargetType="{x:Type xtk:PropertyGridEditorComboBox}" BasedOn="{StaticResource {x:Type ComboBox}}">
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsKeyboardFocusWithin" Value="False" />
                    <Condition Property="IsMouseOver" Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush" Value="Transparent" />
                <Setter Property="Background" Value="Transparent" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>
    <!-- PropertyGrid CheckBox Editors -->
    <Style TargetType="{x:Type xtk:PropertyGridEditorCheckBox}" BasedOn="{StaticResource {x:Type CheckBox}}">
        <Setter Property="Margin" Value="5,0,0,0" />
    </Style>
    <!-- PropertyGrid TextBox Editors -->
    <Style TargetType="{x:Type xtk:PropertyGridEditorTextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsKeyboardFocusWithin" Value="False" />
                    <Condition Property="IsMouseOver" Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush" Value="Transparent" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>
    <!-- PropertyGrid TextBlock Editors -->
    <Style TargetType="{x:Type xtk:PropertyGridEditorTextBlock}" BasedOn="{StaticResource {x:Type TextBlock}}">
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="{DynamicResource DisabledBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>
    <!-- PropertyGrid ColorPicker Editors -->
    <Style TargetType="{x:Type xtk:PropertyGridEditorColorPicker}" BasedOn="{StaticResource {x:Type xtk:ColorPicker}}">
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsKeyboardFocusWithin" Value="False" />
                    <Condition Property="IsMouseOver" Value="False" />
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush" Value="Transparent" />
                <Setter Property="ShowDropDownButton" Value="False" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>



    <Style x:Key="OptionsToggleButtonStyle" TargetType="{x:Type RadioButton}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Height" Value="22" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="ToolTipService.InitialShowDelay" Value="900" />
        <Setter Property="ToolTipService.ShowDuration" Value="20000" />
        <Setter Property="ToolTipService.BetweenShowDelay" Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RadioButton}">
                    <Grid SnapsToDevicePixels="True">
                        <Border x:Name="OuterBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"  />
                        <Border x:Name="MiddleBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" >
                            <Border x:Name="InnerBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" Padding="{TemplateBinding Padding}">
                                <StackPanel x:Name="StackPanel" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
                                    <ContentPresenter x:Name="Content" Content="{TemplateBinding Content}" Margin="1" RenderOptions.BitmapScalingMode="NearestNeighbor" VerticalAlignment="Center" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                                </StackPanel>
                            </Border>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" TargetName="OuterBorder" Value="{DynamicResource  LighterBaseBrush}" />
                            <Setter Property="BorderBrush" TargetName="OuterBorder" Value="{DynamicResource SelectedBrush}" />
                        </Trigger>

                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" TargetName="Content" Value="0.5" />
                            <Setter Property="TextElement.Foreground" TargetName="OuterBorder" Value="{DynamicResource DisabledBrush}" />
                        </Trigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsChecked" Value="true" />
                                <Condition Property="IsEnabled" Value="true" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" TargetName="OuterBorder" Value="{DynamicResource  LighterBaseBrush}" />
                            <Setter Property="BorderBrush" TargetName="OuterBorder" Value="{DynamicResource DarkerSelectedBrush}" />                            
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ClearFilterButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Height" Value="22" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="ToolTipService.InitialShowDelay" Value="900" />
        <Setter Property="ToolTipService.ShowDuration" Value="20000" />
        <Setter Property="ToolTipService.BetweenShowDelay" Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid SnapsToDevicePixels="True">
                        <Border x:Name="OuterBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"  />
                        <Border x:Name="MiddleBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent">
                            <Border x:Name="InnerBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" Padding="{TemplateBinding Padding}">
                                <StackPanel x:Name="StackPanel" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
                                    <ContentPresenter x:Name="Content" Content="{TemplateBinding Content}" Margin="1" RenderOptions.BitmapScalingMode="NearestNeighbor" VerticalAlignment="Center" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                                </StackPanel>
                            </Border>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" TargetName="OuterBorder" Value="{DynamicResource LighterBaseBrush}" />
                            <Setter Property="BorderBrush" TargetName="OuterBorder" Value="{DynamicResource SelectedBrush}" />
                        </Trigger>

                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" TargetName="Content" Value="0.5" />
                            <Setter Property="TextElement.Foreground" TargetName="OuterBorder" Value="{DynamicResource DisabledBrush}" />
                        </Trigger>

                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Background" TargetName="OuterBorder" Value="{DynamicResource LighterBaseBrush}" />
                            <Setter Property="BorderBrush" TargetName="OuterBorder" Value="{DynamicResource DarkerSelectedBrush}" />
                            <Setter Property="BorderBrush" TargetName="InnerBorder" Value="Transparent" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="ExpanderToggleButton" TargetType="{x:Type ToggleButton}">
        <Grid>
            <Rectangle Margin="0,0,0,0" x:Name="Rectangle" Fill="Transparent" />
            <Path HorizontalAlignment="Center" x:Name="Up_Arrow" VerticalAlignment="Center" Fill="{DynamicResource GlyphBrush}" Data="M 0 0 L 4 4 L 8 0 Z" RenderTransformOrigin="0.5,0.5">
                <Path.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform ScaleX="1" ScaleY="1" />
                        <SkewTransform AngleX="0" AngleY="0" />
                        <RotateTransform Angle="-90" />
                        <TranslateTransform X="0" Y="0" />
                    </TransformGroup>
                </Path.RenderTransform>
            </Path>
            <Path Visibility="Collapsed" HorizontalAlignment="Center" x:Name="Down_Arrow" VerticalAlignment="Center" Fill="{DynamicResource GlyphBrush}" Data="M 0 4 L 4 0 L 8 4 Z" RenderTransformOrigin="0.5,0.5">
                <Path.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform ScaleX="1" ScaleY="1" />
                        <SkewTransform AngleX="0" AngleY="0" />
                        <RotateTransform Angle="135" />
                        <TranslateTransform X="0" Y="0" />
                    </TransformGroup>
                </Path.RenderTransform>
            </Path>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsChecked" Value="true">
                <Setter Property="Visibility" Value="Visible" TargetName="Down_Arrow" />
                <Setter Property="Visibility" Value="Collapsed" TargetName="Up_Arrow" />
                <Setter Property="OpacityMask" TargetName="Down_Arrow" Value="#FF000000" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Fill" TargetName="Up_Arrow" Value="{DynamicResource BaseBorderBrush}" />
                <Setter Property="Fill" TargetName="Down_Arrow" Value="{DynamicResource BaseBorderBrush}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="ExpanderStyle" TargetType="{x:Type Expander}">
        <Setter Property="Padding" Value="0" />
        <Setter Property="Background" Value="{DynamicResource LighterBaseBrush}" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Expander}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" x:Name="ContentRow" />
                        </Grid.RowDefinitions>
                        <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="Transparent">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="20" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <ToggleButton Template="{StaticResource ExpanderToggleButton}" IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" OverridesDefaultStyle="True" />
                                <ContentPresenter Grid.Column="1" Margin="1" RecognizesAccessKey="True" ContentSource="Header" TextElement.FontWeight="Bold" />
                            </Grid>
                        </Border>
                        <Border Visibility="Collapsed" Grid.Row="1" x:Name="ExpandSite" Background="{DynamicResource BaseBrush}" Padding="10 0 0 0">
                            <Border BorderThickness="0" Margin="0" Padding="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                                <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Focusable="False" />
                            </Border>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="True">
                            <Setter Property="Visibility" Value="Visible" TargetName="ExpandSite" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" Value="{DynamicResource BaseBrush}" />
                            <Setter Property="Foreground" Value="{DynamicResource DisabledBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="PropertyExpanderStyle" TargetType="{x:Type Expander}">
        <Setter Property="Padding" Value="10 0 0 0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Expander}">
                    <Grid>
                        <Border Visibility="Collapsed" Grid.Row="1" x:Name="ExpandSite" Padding="0 0 0 0">
                            <Border BorderThickness="0" Margin="0" Padding="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                                <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Focusable="False" />
                            </Border>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="True">
                            <Setter Property="Visibility" Value="Visible" TargetName="ExpandSite" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ContextMenu x:Key="{ComponentResourceKey 
                  TypeInTargetAssembly={x:Type xtk:PropertyGrid}, 
                  ResourceId=SelectedObjectAdvancedOptionsMenu}">
        <MenuItem Header="Reset Value" Command="xtk:PropertyItemCommands.ResetValue" />
    </ContextMenu>

    <Style TargetType="{x:Type xtk:PropertyItem}">
        <Setter Property="Background" Value="{DynamicResource BaseBrush}" />
        <!-- Set the margin at 1 pixel bottom to let the horizontal "line" effect appear. -->
        <Setter Property="Margin" Value="0,0,0,1" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:PropertyItem}">
                    <Border ContextMenu="{Binding AdvancedOptionsMenu, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xtk:PropertyGrid}}" ContextMenuService.Placement="Bottom">
                        <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="{Binding NameColumnWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type xtk:PropertyGrid}}}" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <!-- Set the BorderThickness at 1 pixel to the right to let the "vertical line" appear -->
                            <Border x:Name="PART_Name"  Margin="0,0,1,0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
                                <Grid Margin="2,2,2,2" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>

                                    <Grid Margin="{Binding Level, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ExpandableObjectMarginConverter}}">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="15" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>

                                        <ToggleButton x:Name="_expandableButton" Grid.Column="0" Template="{StaticResource ExpanderToggleButton}" OverridesDefaultStyle="True" IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" Visibility="{Binding IsExpandable, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}" />

                                        <TextBlock Foreground="{DynamicResource TextBrush}" x:Name="_text" Grid.Column="1" Text="{Binding DisplayName, RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Stretch" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" IsEnabled="{Binding IsReadOnly, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xtk:PropertyGrid}, Converter={StaticResource InverseBoolConverter}}" />
                                    </Grid>

                                    <Grid Grid.Column="1" HorizontalAlignment="Right" Margin="5,0,5,0" Visibility="{Binding ShowAdvancedOptions, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xtk:PropertyGrid}, Converter={StaticResource BooleanToVisibilityConverter}}" xtk:ContextMenuUtilities.OpenOnMouseLeftButtonClick="True" ContextMenu="{Binding AdvancedOptionsMenu, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xtk:PropertyGrid}}">

                                        <Image x:Name="_optionsImage" Width="11" Height="11" ToolTip="{Binding AdvancedOptionsTooltip, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </Grid>
                                </Grid>
                            </Border>

                            <Border x:Name="PART_Editor" Grid.Column="1" Background="{TemplateBinding Background}" KeyboardNavigation.DirectionalNavigation="None" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                                <ContentControl x:Name="PART_ValueContainer" Content="{TemplateBinding Editor}" Focusable="False" IsTabStop="False" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" IsEnabled="{Binding IsReadOnly, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xtk:PropertyGrid}, Converter={StaticResource InverseBoolConverter}}">
                                </ContentControl>
                            </Border>

                            <Expander x:Name="_propertyExpander" Grid.ColumnSpan="2" Grid.Row="1" IsExpanded="{TemplateBinding IsExpanded}" Style="{StaticResource PropertyExpanderStyle}" IsEnabled="True">
                                <xtk:PropertyItemsControl  x:Name="PART_PropertyItemsControl" IsTabStop="False" Focusable="False" ItemsSource="{Binding Properties, RelativeSource={RelativeSource TemplatedParent}}" ItemContainerStyle="{Binding PropertyContainerStyle, RelativeSource={RelativeSource TemplatedParent}}" >
                                    <ItemsControl.ItemsPanel>
                                        <ItemsPanelTemplate>
                                            <VirtualizingStackPanel />
                                        </ItemsPanelTemplate>
                                    </ItemsControl.ItemsPanel>
                                </xtk:PropertyItemsControl>
                            </Expander>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="PART_Name" Property="TextElement.Foreground" Value="{DynamicResource SelectedBrush}" />
                            <Setter TargetName="PART_Name" Property="Background" Value="{DynamicResource MenuHoverBrush}" />
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="PART_Name" Property="Background" Value="{DynamicResource MenuHoverBrush}" />
                            <Setter TargetName="PART_Name" Property="TextElement.Foreground" Value="{DynamicResource DarkerSelectedBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" TargetName="PART_ValueContainer" Value="{DynamicResource DisabledBrush}" />
                            <Setter Property="Foreground" TargetName="_text" Value="{DynamicResource DisabledBrush}" />
                        </Trigger>
                        <Trigger Property="Validation.HasError" Value="true">
                            <Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors).CurrentItem.ErrorContent}" />
                        </Trigger>
                        <Trigger Property="Visibility" Value="Visible" SourceName="_expandableButton">
                            <Setter Property="Focusable" Value="False" />
                        </Trigger>

                        <DataTrigger Binding="{Binding ElementName=_optionsImage, Path=ToolTip}" Value="{x:Static xtk:StringConstants.Local}">
                            <Setter TargetName="_optionsImage" Property="Source" Value="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/Local11.png" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ElementName=_optionsImage, Path=ToolTip}" Value="{x:Static xtk:StringConstants.Resource}">
                            <Setter TargetName="_optionsImage" Property="Source" Value="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/Resource11.png" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ElementName=_optionsImage, Path=ToolTip}" Value="{x:Static xtk:StringConstants.Databinding}">
                            <Setter TargetName="_optionsImage" Property="Source" Value="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/Database11.png" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ElementName=_optionsImage, Path=ToolTip}" Value="{x:Static xtk:StringConstants.Inheritance}">
                            <Setter TargetName="_optionsImage" Property="Source" Value="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/Inheritance11.png" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ElementName=_optionsImage, Path=ToolTip}" Value="{x:Static xtk:StringConstants.StyleSetter}">
                            <Setter TargetName="_optionsImage" Property="Source" Value="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/Style11.png" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ElementName=_optionsImage, Path=ToolTip}" Value="{x:Static xtk:StringConstants.AdvancedProperties}">
                            <Setter TargetName="_optionsImage" Property="Source" Value="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/AdvancedProperties11.png" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type xtk:PropertyGrid}">
        <Style.Resources>
            <xtk:SelectedObjectConverter x:Key="objectConverter" />
        </Style.Resources>
        <Setter Property="Background" Value="{DynamicResource MenuHoverBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
        <Setter Property="SelectedObjectType" Value="{Binding RelativeSource={RelativeSource Self}, Path=SelectedObject, Converter={StaticResource objectConverter}, ConverterParameter=Type}" />
        <Setter Property="SelectedObjectTypeName" Value="{Binding RelativeSource={RelativeSource Self}, Path=SelectedObject, Converter={StaticResource objectConverter}, ConverterParameter=TypeName}" />
        <Setter Property="SelectedObjectName" Value="{Binding RelativeSource={RelativeSource Self}, Path=SelectedObject, Converter={StaticResource objectConverter}, ConverterParameter=SelectedObjectName}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:PropertyGrid}">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{DynamicResource DefaultCornerRadius}">
                        <Grid Margin="{TemplateBinding Padding}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition />
                                <RowDefinition Height="5" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <StackPanel Orientation="Horizontal" Margin="6,2,0,4" Visibility="{Binding ShowTitle, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}">
                                <TextBlock Text="{TemplateBinding SelectedObjectTypeName}" FontWeight="Bold" />
                                <TextBlock Text="{TemplateBinding SelectedObjectName}" Margin="5,0,0,0" />
                            </StackPanel>

                            <Grid x:Name="toolsContainer" Grid.Row="1" Margin="4,0,4,4">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Grid x:Name="sortButtonContainer" Margin="4" Visibility="{Binding ShowSortOptions, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}">
                                    <StackPanel Orientation="Horizontal" Margin="1">
                                        <RadioButton IsChecked="{Binding IsCategorized, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center" Style="{StaticResource OptionsToggleButtonStyle}" ToolTip="Categorized">
                                            <Image Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/Categorize16.png" Width="16" Height="16" />
                                        </RadioButton>
                                        <RadioButton IsChecked="{Binding IsCategorized, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverter}, Mode=OneWay}" VerticalAlignment="Center" Style="{StaticResource OptionsToggleButtonStyle}" ToolTip="Alphabetical">
                                            <Image Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/SortAscending16.png" Width="16" Height="16" />
                                        </RadioButton>
                                    </StackPanel>
                                </Grid>

                                <Border x:Name="searchBoxContainer" Grid.Column="1" Margin="4,4,0,4"  BorderBrush="{DynamicResource BaseBorderBrush}" BorderThickness="0" Visibility="{Binding ShowSearchBox, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*" />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <xtk:WatermarkTextBox x:Name="_txtFilter" Background="{DynamicResource DarkerBaseBrush}" Text="{Binding Filter, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" Watermark="{TemplateBinding FilterWatermark}">
                                        </xtk:WatermarkTextBox>

                                        <Button Grid.Column="1" Command="xtk:PropertyGridCommands.ClearFilter" Style="{StaticResource ClearFilterButtonStyle}" HorizontalAlignment="Left">
                                            <Image Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/PropertyGrid/Images/ClearFilter16.png" Width="16" Height="16" />
                                        </Button>
                                    </Grid>
                                </Border>
                            </Grid>

                            <Grid Grid.Row="2" Background="{DynamicResource BaseBrush}">
                                <ScrollViewer VerticalScrollBarVisibility="Auto">
                                    <xtk:PropertyItemsControl x:Name="PART_PropertyItemsControl" IsTabStop="False" Focusable="False" ItemsSource="{Binding Properties, RelativeSource={RelativeSource TemplatedParent}}" ItemContainerStyle="{Binding PropertyContainerStyle, RelativeSource={RelativeSource TemplatedParent}}" Background="{DynamicResource BaseBrush}" VerticalAlignment="Top">
                                        <ItemsControl.ItemsPanel>
                                            <ItemsPanelTemplate>
                                                <VirtualizingStackPanel />
                                            </ItemsPanelTemplate>
                                        </ItemsControl.ItemsPanel>

                                        <ItemsControl.GroupStyle>
                                            <GroupStyle>
                                                <GroupStyle.ContainerStyle>
                                                    <Style TargetType="{x:Type GroupItem}">
                                                        <Setter Property="Template">
                                                            <Setter.Value>
                                                                <ControlTemplate>
                                                                    <Border>
                                                                        <Expander  Header="{Binding Name}" Style="{StaticResource ExpanderStyle}">
                                                                            <ItemsPresenter />
                                                                        </Expander>
                                                                    </Border>
                                                                </ControlTemplate>
                                                            </Setter.Value>
                                                        </Setter>
                                                    </Style>
                                                </GroupStyle.ContainerStyle>
                                            </GroupStyle>
                                        </ItemsControl.GroupStyle>

                                    </xtk:PropertyItemsControl>
                                </ScrollViewer>

                                <Thumb x:Name="PART_DragThumb" HorizontalAlignment="Left" Width="5" Margin="6,0,0,0" Cursor="SizeWE">
                                    <Thumb.Template>
                                        <ControlTemplate>
                                            <Border Background="Transparent" />
                                        </ControlTemplate>
                                    </Thumb.Template>
                                </Thumb>

                            </Grid>

                            <GridSplitter Height="3" Grid.Row="3" HorizontalAlignment="Stretch" Visibility="{Binding ShowSummary, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}" />
                            <StackPanel Grid.Row="4" Margin="0,0,0,5" Visibility="{Binding ShowSummary, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}">
                                <TextBlock Padding="2 2 2 0" FontWeight="Bold" Text="{Binding SelectedPropertyItem.DisplayName, RelativeSource={RelativeSource TemplatedParent}}" />
                                <TextBlock Padding="5 2 2 0" TextWrapping="WrapWithOverflow" Text="{Binding SelectedPropertyItem.Description, RelativeSource={RelativeSource TemplatedParent}}" />
                            </StackPanel>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition SourceName="searchBoxContainer" Property="Visibility" Value="Collapsed" />
                                <Condition SourceName="sortButtonContainer" Property="Visibility" Value="Collapsed" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="toolsContainer" Property="Visibility" Value="Collapsed" />
                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" Value="{DynamicResource BaseBrush}" />
                            <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    
    <!-- MultiLineTextEditor stuff -->
    <Style x:Key="ToggleButtonStyle" TargetType="ToggleButton">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Grid SnapsToDevicePixels="True">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True" Name="border">
                                <ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                            </Border>
                            <ToggleButton x:Name="ToggleButtonChrome" Grid.Column="1" IsChecked="{Binding IsOpen, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xtk:MultiLineTextEditor}}" IsEnabled="{Binding IsEnabled, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=xtk:MultiLineTextEditor}}" Style="{StaticResource ToolkitToggleButton}" >                                
                            </ToggleButton>
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{DynamicResource DisabledBrush}" />
                        </Trigger>                        
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type xtk:MultiLineTextEditor}">
        <Setter Property="Background" Value="{DynamicResource DarkerBaseBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThickness}" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Padding" Value="2,0,0,0" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="DropDownWidth" Value="{Binding ActualWidth, RelativeSource={RelativeSource Self}}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:MultiLineTextEditor}">
                    <Grid x:Name="Root" >
                        <ToggleButton x:Name="PART_DropDownButton" Grid.Column="1" IsTabStop="True" MinHeight="22" SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" IsChecked="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ToolkitToggleButton}" IsHitTestVisible="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverter}}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" />
                        <Popup IsOpen="{Binding IsChecked, ElementName=PART_DropDownButton}" StaysOpen="False" Placement="Bottom" SnapsToDevicePixels="True" AllowsTransparency="True" Focusable="False" PopupAnimation="None" Width="{TemplateBinding DropDownWidth}" Height="{TemplateBinding DropDownHeight}" HorizontalAlignment="Center">
                            <Border Margin="11,0,11,11" BorderThickness="1" BorderBrush="{DynamicResource PopupBorderBrush}">
                                <Border.Background>
                                    <SolidColorBrush Color="{DynamicResource Base6Color}" />
                                </Border.Background>
                                <Border.Effect>
                                    <DropShadowEffect BlurRadius="10" ShadowDepth="0" Color="{DynamicResource Base6Color}" />
                                </Border.Effect>
                                <Grid Name="popupgrid">
                                    <TextBox x:Name="PART_TextBox" AcceptsReturn="true" TextWrapping="{TemplateBinding TextWrapping}" Padding="{TemplateBinding Padding}"  VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" SpellCheck.IsEnabled="{TemplateBinding IsSpellCheckEnabled}" IsReadOnly="{TemplateBinding IsReadOnly}" Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}}" TextAlignment="{TemplateBinding TextAlignment}"  />
                                    <Thumb x:Name="PART_ResizeThumb" HorizontalAlignment="Right" VerticalAlignment="Bottom" Cursor="SizeNWSE">
                                        <Thumb.Template>
                                            <ControlTemplate TargetType="{x:Type Thumb}">
                                                <Grid Background="Transparent">
                                                    <Path Data="M0.5,6.5 L6.5,0.5 M6.5,3.5 L3.5,6.5" Stroke="{DynamicResource GlyphBrush}" StrokeThickness="1" />
                                                </Grid>
                                            </ControlTemplate>
                                        </Thumb.Template>
                                    </Thumb>
                                </Grid>
                            </Border>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="BorderBrush" TargetName="PART_DropDownButton" Value="{DynamicResource DisabledBorderBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    
    <!-- Range slider stuff -->
    <conv:SliderThumbWidthConverter  x:Key="SliderThumbWidthConverter" />
    <xtk:SolidColorBrushToColorConverter x:Key="SolidColorBrushToColorConverter" />
    <Style x:Key="DefaultRangeStyle" TargetType="{x:Type RepeatButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Grid>
                        <Rectangle x:Name="MainBorder" Fill="Transparent" Opacity="1" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <ControlTemplate x:Key="LowerThumbTemplate" TargetType="{x:Type Thumb}">
        <Grid>
            <Rectangle x:Name="BackgroundFadingRect" Fill="Red" Width="11" Height="20" />
            <Rectangle x:Name="MainBorder" Fill="{DynamicResource LighterBaseBrush}" StrokeThickness="{DynamicResource DefaultBorderThicknessNumber}" Stroke="{DynamicResource VeryLighterBaseBrush}" Opacity="1" Width="11" Height="20" ToolTip="{Binding RelativeSource={RelativeSource AncestorType={x:Type xtk:RangeSlider}}, Path=LowerValue, StringFormat=\{0:00.00\}}" SnapsToDevicePixels="True" />
            <Border ClipToBounds="True">
                <Border Name="glow" BorderThickness="{DynamicResource GlowBorderThickness}" BorderBrush="{DynamicResource ButtonGlowBrush}" Margin="{DynamicResource GlowBorderMargin}" Visibility="Collapsed" Effect="{DynamicResource ButtonHoverGlowEffect}" />
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type xtk:RangeSlider}}, Path=LowerThumbBackground, Converter={StaticResource SolidColorBrushToColorConverter}}" Value="Transparent">
                <Setter Property="Visibility" TargetName="BackgroundFadingRect" Value="Collapsed" />
            </DataTrigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Opacity" TargetName="MainBorder" Value="0.75" />
            </Trigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type xtk:RangeSlider}}, Path=LowerThumbBackground}" Value="{x:Null}" />
                    <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}" Value="True" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Opacity" TargetName="MainBorder" Value="1" />
                <Setter Property="Stroke" TargetName="MainBorder" Value="{DynamicResource SelectedBrush}" />
                <Setter Property="Fill" TargetName="MainBorder" Value="{DynamicResource LighterBaseBrush}" />
                <Setter TargetName="glow" Property="Visibility" Value="Visible" />

            </MultiDataTrigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Fill" TargetName="MainBorder" Value="{DynamicResource BaseBrush}" />
                <Setter Property="Stroke" TargetName="MainBorder" Value="{DynamicResource DisabledBorderBrush}" />
            </Trigger>
            <Trigger Property="IsDragging" Value="True">
                <Setter TargetName="MainBorder" Property="Stroke" Value="{DynamicResource DarkerSelectedBrush}" />
                <Setter TargetName="glow" Property="Effect" Value="{DynamicResource ButtonPressedGlowEffect}" />
                <Setter TargetName="glow" Property="Visibility" Value="Visible" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="HigherThumbTemplate" TargetType="{x:Type Thumb}">
        <Grid>
            <Rectangle x:Name="BackgroundFadingRect" Fill="Black" Width="11" Height="20" />
            <Rectangle Name="MainBorder" Fill="{DynamicResource LighterBaseBrush}" StrokeThickness="{DynamicResource DefaultBorderThicknessNumber}" Stroke="{DynamicResource VeryLighterBaseBrush}" Opacity="1" Width="11" Height="20" ToolTip="{Binding RelativeSource={RelativeSource AncestorType={x:Type xtk:RangeSlider}}, Path=HigherValue, StringFormat=\{0:00.00\}}" SnapsToDevicePixels="True" />
            <Border ClipToBounds="True">
                <Border Name="glow" BorderThickness="{DynamicResource GlowBorderThickness}" BorderBrush="{DynamicResource ButtonGlowBrush}" Margin="{DynamicResource GlowBorderMargin}" Visibility="Collapsed" Effect="{DynamicResource ButtonHoverGlowEffect}" />
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type xtk:RangeSlider}}, Path=HigherThumbBackground, Converter={StaticResource SolidColorBrushToColorConverter}}" Value="Transparent">
                <Setter Property="Visibility" TargetName="BackgroundFadingRect" Value="Collapsed" />
            </DataTrigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Opacity" TargetName="MainBorder" Value="0.75" />
            </Trigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type xtk:RangeSlider}}, Path=HigherThumbBackground}" Value="{x:Null}" />
                    <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}" Value="True" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Opacity" TargetName="MainBorder" Value="1" />
                <Setter Property="Stroke" TargetName="MainBorder" Value="{DynamicResource SelectedBrush}" />
                <Setter TargetName="glow" Property="Visibility" Value="Visible" />
                <Setter Property="Fill" TargetName="MainBorder" Value="{DynamicResource LighterBaseBrush}" />
            </MultiDataTrigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Fill" TargetName="MainBorder" Value="{DynamicResource BaseBrush}" />
                <Setter Property="Stroke" TargetName="MainBorder" Value="{DynamicResource DisabledBorderBrush}" />
            </Trigger>
            <Trigger Property="IsDragging" Value="True">
                <Setter TargetName="MainBorder" Property="Stroke" Value="{DynamicResource DarkerSelectedBrush}" />
                <Setter TargetName="glow" Property="Effect" Value="{DynamicResource ButtonPressedGlowEffect}" />
                <Setter TargetName="glow" Property="Visibility" Value="Visible" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="LowerSliderTemplate" TargetType="{x:Type Slider}">
        <Border SnapsToDevicePixels="true" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Track x:Name="PART_Track" Grid.Row="1">
                    <Track.Thumb>
                        <Thumb x:Name="Thumb" Template="{StaticResource LowerThumbTemplate}">
                        </Thumb>
                    </Track.Thumb>
                </Track>
            </Grid>
        </Border>
    </ControlTemplate>
    <ControlTemplate x:Key="HigherSliderTemplate" TargetType="{x:Type Slider}">
        <Border SnapsToDevicePixels="true" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Track x:Name="PART_Track" Grid.Row="1">
                    <Track.Thumb>
                        <Thumb x:Name="Thumb" Template="{StaticResource HigherThumbTemplate}" />
                    </Track.Thumb>
                </Track>
            </Grid>
        </Border>
    </ControlTemplate>
    <ControlTemplate x:Key="VerticalRangeSlider" TargetType="{x:Type xtk:RangeSlider}">
        <Grid Width="50">
            <Grid.RowDefinitions>
                <RowDefinition Height="{Binding ., ElementName=PART_HigherSlider, Converter={StaticResource SliderThumbWidthConverter}, ConverterParameter=1}" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="{Binding ., ElementName=PART_LowerSlider, Converter={StaticResource SliderThumbWidthConverter}, ConverterParameter=1}" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" MinWidth="50" />
            </Grid.ColumnDefinitions>

            <Border Grid.Column="1" Grid.Row="1" Grid.RowSpan="3"  Background="{DynamicResource BaseBorderBrush}" VerticalAlignment="Stretch" HorizontalAlignment="Center" Width="2" Name="b" />

            <RepeatButton x:Name="PART_LowerRange" Height="{TemplateBinding LowerRangeWidth}" Width="15" Grid.Column="1" Grid.Row="3" Background="{TemplateBinding LowerRangeBackground}" Style="{Binding LowerRangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}" SnapsToDevicePixels="True" />

            <RepeatButton Height="{TemplateBinding RangeWidth}" Width="15" Grid.Row="2" Grid.Column="1" Background="{TemplateBinding RangeBackground}" Style="{Binding RangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}" SnapsToDevicePixels="True" />

            <RepeatButton x:Name="PART_HigherRange" Height="{TemplateBinding HigherRangeWidth}" Width="15" Grid.Row="1" Grid.Column="1" Background="{TemplateBinding HigherRangeBackground}" Style="{Binding HigherRangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}" SnapsToDevicePixels="True" />
<Slider x:Name="PART_LowerSlider" Grid.Column="1" Orientation="Vertical" Grid.RowSpan="5" Minimum="{TemplateBinding Minimum}" Maximum="{TemplateBinding Maximum}" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type xtk:RangeSlider}}, Mode=TwoWay, Path=LowerValue, StringFormat=\{0:00.00\}}">
                <Slider.Template>
                    <ControlTemplate TargetType="{x:Type Slider}">
                        <Border SnapsToDevicePixels="true" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Name="b">
                            <Grid>
                                <Track x:Name="PART_Track">
                                    <Track.Thumb>
                                        <Thumb x:Name="Thumb">
                                            <Thumb.Template>
                                                <ControlTemplate TargetType="{x:Type Thumb}">
                                                    <Grid>
                                                        <Rectangle x:Name="BackgroundFadingRect"  Width="20" Height="11" />
                                                        <Rectangle x:Name="MainBorder" Fill="{DynamicResource LighterBaseBrush}" StrokeThickness="{DynamicResource DefaultBorderThicknessNumber}" Stroke="{DynamicResource VeryLighterBaseBrush}" Width="20" Height="11" Opacity="1" ToolTip="{Binding RelativeSource={RelativeSource AncestorType={x:Type xtk:RangeSlider}}, Path=LowerValue, StringFormat=\{0:00.00\}}" SnapsToDevicePixels="True" />
                                                        <Border ClipToBounds="True" Width="20" Height="11">
                                                            <Border Name="glow" BorderThickness="{DynamicResource GlowBorderThickness}" BorderBrush="{DynamicResource ButtonGlowBrush}" Margin="{DynamicResource GlowBorderMargin}" Visibility="Collapsed" Effect="{DynamicResource ButtonHoverGlowEffect}" />
                                                        </Border>
                                                    </Grid>
                                                    <ControlTemplate.Triggers>
                                                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type xtk:RangeSlider}}, Path=LowerThumbBackground, Converter={StaticResource SolidColorBrushToColorConverter}}" Value="Transparent">
                                                            <Setter Property="Visibility" TargetName="BackgroundFadingRect" Value="Collapsed" />
                                                        </DataTrigger>
                                                        <Trigger Property="IsMouseOver" Value="True">
                                                            <Setter Property="Opacity" TargetName="MainBorder" Value="0.75" />
                                                        </Trigger>
                                                        <MultiDataTrigger>
                                                            <MultiDataTrigger.Conditions>
                                                                <Condition Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type xtk:RangeSlider}}, Path=LowerThumbBackground}" Value="{x:Null}" />
                                                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}" Value="True" />
                                                            </MultiDataTrigger.Conditions>
                                                            <Setter Property="Opacity" TargetName="MainBorder" Value="1" />
                                                            <Setter TargetName="glow" Property="Visibility" Value="Visible" />
                                                            <Setter Property="Stroke" TargetName="MainBorder" Value="{DynamicResource SelectedBrush}" />
                                                        </MultiDataTrigger>
                                                        <Trigger Property="IsDragging" Value="True">
                                                            <Setter TargetName="MainBorder" Property="Stroke" Value="{DynamicResource DarkerSelectedBrush}" />
                                                            <Setter TargetName="glow" Property="Effect" Value="{DynamicResource ButtonPressedGlowEffect}" />
                                                            <Setter TargetName="glow" Property="Visibility" Value="Visible" />
                                                        </Trigger>
                                                        <Trigger Property="IsEnabled" Value="false">
                                                            <Setter Property="Fill" TargetName="MainBorder" Value="{DynamicResource BaseBrush}" />
                                                            <Setter Property="Stroke" TargetName="MainBorder" Value="{DynamicResource DisabledBorderBrush}" />
                                                        </Trigger>
                                                    </ControlTemplate.Triggers>
                                                </ControlTemplate>
                                            </Thumb.Template>
                                        </Thumb>
                                    </Track.Thumb>
                                </Track>
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Slider.Template>
            </Slider>
<Slider x:Name="PART_HigherSlider" Grid.Column="1" Grid.RowSpan="5" Orientation="Vertical" Minimum="{TemplateBinding Minimum}" Maximum="{TemplateBinding Maximum}" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type xtk:RangeSlider}}, Mode=TwoWay, Path=HigherValue, StringFormat=\{0:00.00\}}">
                <Slider.Template>
                    <ControlTemplate TargetType="{x:Type Slider}">
                        <Border SnapsToDevicePixels="true" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Name="b">
                            <Grid>
                                <Track x:Name="PART_Track">
                                    <Track.Thumb>
                                        <Thumb x:Name="Thumb">
                                            <Thumb.Template>
                                                <ControlTemplate TargetType="{x:Type Thumb}">
                                                    <Grid>
                                                        <Rectangle x:Name="BackgroundFadingRect" Width="20" Height="11" />
                                                        <Rectangle Name="MainBorder" Fill="{DynamicResource LighterBaseBrush}" StrokeThickness="{DynamicResource DefaultBorderThicknessNumber}" Stroke="{DynamicResource VeryLighterBaseBrush}" Width="20" Height="11" ToolTip="{Binding RelativeSource={RelativeSource AncestorType={x:Type xtk:RangeSlider}}, Path=HigherValue, StringFormat=\{0:00.00\}}" SnapsToDevicePixels="True" />
                                                        <Border ClipToBounds="True" Width="20" Height="11">
                                                            <Border Name="glow" BorderThickness="{DynamicResource GlowBorderThickness}" BorderBrush="{DynamicResource ButtonGlowBrush}" Margin="{DynamicResource GlowBorderMargin}" Visibility="Collapsed" Effect="{DynamicResource ButtonHoverGlowEffect}" />
                                                        </Border>
                                                    </Grid>
                                                    <ControlTemplate.Triggers>
                                                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type xtk:RangeSlider}}, Path=HigherThumbBackground, Converter={StaticResource SolidColorBrushToColorConverter}}" Value="Transparent">
                                                            <Setter Property="Visibility" TargetName="BackgroundFadingRect" Value="Collapsed" />
                                                        </DataTrigger>
                                                        <Trigger Property="IsMouseOver" Value="True">
                                                            <Setter TargetName="MainBorder" Property="Opacity" Value="0.75" />
                                                        </Trigger>
                                                        <MultiDataTrigger>
                                                            <MultiDataTrigger.Conditions>
                                                                <Condition Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type xtk:RangeSlider}}, Path=HigherThumbBackground}" Value="{x:Null}" />
                                                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}" Value="True" />
                                                            </MultiDataTrigger.Conditions>
                                                            <Setter TargetName="glow" Property="Visibility" Value="Visible" />
                                                            <Setter Property="Opacity" TargetName="MainBorder" Value="1" />
                                                            <Setter Property="Stroke" TargetName="MainBorder" Value="{DynamicResource SelectedBrush}" />
                                                        </MultiDataTrigger>
                                                        <Trigger Property="IsDragging" Value="True">
                                                            <Setter TargetName="MainBorder" Property="Stroke" Value="{DynamicResource DarkerSelectedBrush}" />
                                                            <Setter TargetName="glow" Property="Effect" Value="{DynamicResource ButtonPressedGlowEffect}" />
                                                            <Setter TargetName="glow" Property="Visibility" Value="Visible" />
                                                        </Trigger>
                                                        <Trigger Property="IsEnabled" Value="false">
                                                            <Setter Property="Fill" TargetName="MainBorder" Value="{DynamicResource BaseBrush}" />
                                                            <Setter Property="Stroke" TargetName="MainBorder" Value="{DynamicResource DisabledBorderBrush}" />
                                                        </Trigger>
                                                    </ControlTemplate.Triggers>
                                                </ControlTemplate>
                                            </Thumb.Template>
                                        </Thumb>
                                    </Track.Thumb>
                                </Track>
                            </Grid>
                        </Border>                        
                    </ControlTemplate>
                </Slider.Template>
            </Slider>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Background" TargetName="b" Value="{DynamicResource DisabledBorderBrush}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <Style TargetType="{x:Type xtk:RangeSlider}">
        <Setter Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xtk:RangeSlider}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <!-- //#TODODOC 
                        Get Thumbs's width to set the good RangeSlider width.-->
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="{Binding ., ElementName=PART_LowerSlider, Converter={StaticResource SliderThumbWidthConverter}, ConverterParameter=0}" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="{Binding ., ElementName=PART_HigherSlider, Converter={StaticResource SliderThumbWidthConverter}, ConverterParameter=0}" />
                        </Grid.ColumnDefinitions>

                        <Border Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Background="{TemplateBinding BorderBrush}" VerticalAlignment="Center" Height="2" />

                        <RepeatButton x:Name="PART_LowerRange" Width="{TemplateBinding LowerRangeWidth}" Grid.Column="1" Grid.Row="1" Background="{TemplateBinding LowerRangeBackground}" Style="{Binding LowerRangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}" SnapsToDevicePixels="True" />

                        <RepeatButton Width="{TemplateBinding RangeWidth}" Grid.Row="1" Grid.Column="2" Background="{TemplateBinding RangeBackground}" Style="{Binding RangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}" SnapsToDevicePixels="True" />

                        <RepeatButton x:Name="PART_HigherRange" Width="{TemplateBinding HigherRangeWidth}" Grid.Row="1" Grid.Column="3" Background="{TemplateBinding HigherRangeBackground}" Style="{Binding HigherRangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}" SnapsToDevicePixels="True" />

                        <!-- Margin is set in CodeBehind, based on HigherSlider's Thumb width -->
                        <Slider x:Name="PART_LowerSlider" Grid.Row="1" Grid.ColumnSpan="5" Template="{StaticResource LowerSliderTemplate}" Minimum="{TemplateBinding Minimum}" Maximum="{TemplateBinding Maximum}" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type xtk:RangeSlider}}, Mode=TwoWay, Path=LowerValue, StringFormat=\{0:00.00\}}">
                        </Slider>

                        <!-- Margin is set in CodeBehind, based on LowerSlider's Thumb width -->
                        <Slider x:Name="PART_HigherSlider" Grid.Row="1" Grid.ColumnSpan="5" Template="{StaticResource HigherSliderTemplate}" Minimum="{TemplateBinding Minimum}" Maximum="{TemplateBinding Maximum}" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type xtk:RangeSlider}}, Mode=TwoWay, Path=HigherValue, StringFormat=\{0:00.00\}}">
                        </Slider>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Template" Value="{StaticResource VerticalRangeSlider}" />
            </Trigger>
        </Style.Triggers>


    </Style>

</ResourceDictionary>